feat: Implement resume strategy engine and session content parser

- Added `resume-strategy.ts` to determine optimal resume approaches including native, prompt concatenation, and hybrid modes.
- Introduced `determineResumeStrategy` function to evaluate various resume scenarios.
- Created utility functions for building context prefixes and formatting outputs in plain, YAML, and JSON formats.
- Added `session-content-parser.ts` to parse native CLI tool session files supporting Gemini/Qwen JSON and Codex JSONL formats.
- Implemented parsing logic for different session formats, including error handling for invalid lines.
- Provided functions to format conversations and extract user-assistant pairs from parsed sessions.
This commit is contained in:
catlog22
2025-12-13 20:29:19 +08:00
parent 32217f87fd
commit 52935d4b8e
26 changed files with 9387 additions and 86 deletions

View File

@@ -27,6 +27,9 @@ const i18n = {
'nav.explorer': 'Explorer',
'nav.status': 'Status',
'nav.history': 'History',
'nav.memory': 'Memory',
'nav.contextMemory': 'Context',
'nav.promptHistory': 'Prompts',
// Sidebar - Sessions section
'nav.sessions': 'Sessions',
@@ -78,6 +81,8 @@ const i18n = {
'title.sessionDetail': 'Session Detail',
'title.liteTaskDetail': 'Lite Task Detail',
'title.hookManager': 'Hook Manager',
'title.memoryModule': 'Memory Module',
'title.promptHistory': 'Prompt History',
// Search
'search.placeholder': 'Search...',
@@ -207,6 +212,8 @@ const i18n = {
'cli.storageBackendDesc': 'CLI history stored in SQLite with FTS search',
'cli.smartContext': 'Smart Context',
'cli.smartContextDesc': 'Auto-analyze prompt and add relevant file paths',
'cli.nativeResume': 'Native Resume',
'cli.nativeResumeDesc': 'Use native tool resume (gemini -r, qwen --resume, codex resume)',
'cli.maxContextFiles': 'Max Context Files',
'cli.maxContextFilesDesc': 'Maximum files to include in smart context',
@@ -424,6 +431,15 @@ const i18n = {
'hook.wizard.keywordMatchingDesc': 'Load specific SKILLs when keywords are detected in prompt',
'hook.wizard.autoDetection': 'Auto Detection',
'hook.wizard.autoDetectionDesc': 'Automatically detect and load SKILLs by name in prompt',
'hook.wizard.memorySetup': 'Memory Module Setup',
'hook.wizard.memorySetupDesc': 'Configure automatic context tracking (lightweight metadata recording)',
'hook.wizard.fileReadTracker': 'File Read Tracker',
'hook.wizard.fileReadTrackerDesc': 'Track file reads to build context heatmap',
'hook.wizard.fileWriteTracker': 'File Write Tracker',
'hook.wizard.fileWriteTrackerDesc': 'Track file modifications to identify core modules',
'hook.wizard.promptTracker': 'Prompt Tracker',
'hook.wizard.promptTrackerDesc': 'Record user prompts for pattern analysis',
'hook.wizard.selectTrackers': 'Select Trackers',
// Hook Wizard Labels
'hook.wizard.cliTools': 'CLI Tools:',
@@ -510,6 +526,71 @@ const i18n = {
'footer.generated': 'Generated:',
'footer.version': 'CCW Dashboard v1.0',
// Prompt History
'prompt.timeline': 'Prompt Timeline',
'prompt.searchPlaceholder': 'Search prompts...',
'prompt.allProjects': 'All Projects',
'prompt.currentProject': 'Current Project',
'prompt.noPromptsFound': 'No Prompts Found',
'prompt.noPromptsText': 'No prompts found matching your search criteria.',
'prompt.insights': 'Insights & Suggestions',
'prompt.analyze': 'Analyze',
'prompt.analyzing': 'Analyzing...',
'prompt.selectTool': 'Select Tool',
'prompt.quality': 'Quality',
'prompt.intent': 'Intent',
'prompt.project': 'Project',
'prompt.session': 'Session',
'prompt.noInsights': 'No insights yet',
'prompt.noInsightsText': 'Select a CLI tool and click Analyze to generate insights.',
'prompt.loadingInsights': 'Generating insights...',
'prompt.insightsError': 'Failed to generate insights',
'prompt.intent.implement': 'Implement',
'prompt.intent.fix': 'Fix',
'prompt.intent.explore': 'Explore',
'prompt.intent.debug': 'Debug',
'prompt.intent.refactor': 'Refactor',
'prompt.intent.test': 'Test',
'prompt.intent.document': 'Document',
'prompt.intent.general': 'General',
'prompt.timeJustNow': 'Just now',
'prompt.timeMinutesAgo': '{count} min ago',
'prompt.timeHoursAgo': '{count} hours ago',
'prompt.timeDaysAgo': '{count} days ago',
// Memory Module
'memory.contextHotspots': 'Context Hotspots',
'memory.mostRead': 'Most Read Files',
'memory.mostEdited': 'Most Edited Files',
'memory.today': 'Today',
'memory.week': 'Week',
'memory.allTime': 'All Time',
'memory.noData': 'No data available',
'memory.memoryGraph': 'Memory Graph',
'memory.nodes': 'nodes',
'memory.resetView': 'Reset View',
'memory.file': 'File',
'memory.module': 'Module',
'memory.component': 'Component',
'memory.noGraphData': 'No graph data available',
'memory.d3NotLoaded': 'D3.js not loaded',
'memory.recentContext': 'Recent Context',
'memory.activities': 'activities',
'memory.searchContext': 'Search context...',
'memory.noRecentActivity': 'No recent activity',
'memory.reads': 'Reads',
'memory.edits': 'Edits',
'memory.prompts': 'Prompts',
'memory.nodeDetails': 'Node Details',
'memory.heat': 'Heat',
'memory.associations': 'Associations',
'memory.type': 'Type',
'memory.relatedNodes': 'Related Nodes',
'memory.noAssociations': 'No associations found',
'memory.justNow': 'Just now',
'memory.minutesAgo': 'minutes ago',
'memory.hoursAgo': 'hours ago',
// Common
'common.cancel': 'Cancel',
'common.create': 'Create',
@@ -547,6 +628,9 @@ const i18n = {
'nav.explorer': '文件浏览器',
'nav.status': '状态',
'nav.history': '历史',
'nav.memory': '记忆',
'nav.contextMemory': '活动',
'nav.promptHistory': '洞察',
// Sidebar - Sessions section
'nav.sessions': '会话',
@@ -598,7 +682,9 @@ const i18n = {
'title.sessionDetail': '会话详情',
'title.liteTaskDetail': '轻量任务详情',
'title.hookManager': '钩子管理',
'title.memoryModule': '记忆模块',
'title.promptHistory': '提示历史',
// Search
'search.placeholder': '搜索...',
@@ -727,6 +813,8 @@ const i18n = {
'cli.storageBackendDesc': 'CLI 历史使用 SQLite 存储,支持全文搜索',
'cli.smartContext': '智能上下文',
'cli.smartContextDesc': '自动分析提示词并添加相关文件路径',
'cli.nativeResume': '原生恢复',
'cli.nativeResumeDesc': '使用工具原生恢复命令 (gemini -r, qwen --resume, codex resume)',
'cli.maxContextFiles': '最大上下文文件数',
'cli.maxContextFilesDesc': '智能上下文包含的最大文件数',
@@ -944,6 +1032,15 @@ const i18n = {
'hook.wizard.keywordMatchingDesc': '当提示中检测到关键词时加载特定 SKILL',
'hook.wizard.autoDetection': '自动检测',
'hook.wizard.autoDetectionDesc': '根据提示中的名称自动检测并加载 SKILL',
'hook.wizard.memorySetup': '记忆模块设置',
'hook.wizard.memorySetupDesc': '配置自动上下文跟踪(轻量级元数据记录)',
'hook.wizard.fileReadTracker': '文件读取追踪器',
'hook.wizard.fileReadTrackerDesc': '追踪文件读取以构建上下文热图',
'hook.wizard.fileWriteTracker': '文件写入追踪器',
'hook.wizard.fileWriteTrackerDesc': '追踪文件修改以识别核心模块',
'hook.wizard.promptTracker': '提示追踪器',
'hook.wizard.promptTrackerDesc': '记录用户提示用于模式分析',
'hook.wizard.selectTrackers': '选择追踪器',
// Hook Wizard Labels
'hook.wizard.cliTools': 'CLI 工具:',
@@ -1029,7 +1126,72 @@ const i18n = {
// Footer
'footer.generated': '生成时间:',
'footer.version': 'CCW 控制面板 v1.0',
// Prompt History
'prompt.timeline': '提示词时间线',
'prompt.searchPlaceholder': '搜索提示词...',
'prompt.allProjects': '所有项目',
'prompt.currentProject': '当前项目',
'prompt.noPromptsFound': '未找到提示词',
'prompt.noPromptsText': '没有符合搜索条件的提示词。',
'prompt.insights': '洞察与建议',
'prompt.analyze': '分析',
'prompt.analyzing': '分析中...',
'prompt.selectTool': '选择工具',
'prompt.quality': '质量',
'prompt.intent': '意图',
'prompt.project': '项目',
'prompt.session': '会话',
'prompt.noInsights': '暂无洞察',
'prompt.noInsightsText': '选择 CLI 工具并点击分析以生成洞察。',
'prompt.loadingInsights': '正在生成洞察...',
'prompt.insightsError': '生成洞察失败',
'prompt.intent.implement': '实现',
'prompt.intent.fix': '修复',
'prompt.intent.explore': '探索',
'prompt.intent.debug': '调试',
'prompt.intent.refactor': '重构',
'prompt.intent.test': '测试',
'prompt.intent.document': '文档',
'prompt.intent.general': '通用',
'prompt.timeJustNow': '刚刚',
'prompt.timeMinutesAgo': '{count} 分钟前',
'prompt.timeHoursAgo': '{count} 小时前',
'prompt.timeDaysAgo': '{count} 天前',
// Memory Module
'memory.contextHotspots': '上下文热点',
'memory.mostRead': '最常读取的文件',
'memory.mostEdited': '最常编辑的文件',
'memory.today': '今天',
'memory.week': '本周',
'memory.allTime': '全部时间',
'memory.noData': '无可用数据',
'memory.memoryGraph': '记忆图谱',
'memory.nodes': '节点',
'memory.resetView': '重置视图',
'memory.file': '文件',
'memory.module': '模块',
'memory.component': '组件',
'memory.noGraphData': '无图谱数据',
'memory.d3NotLoaded': 'D3.js 未加载',
'memory.recentContext': '最近上下文',
'memory.activities': '活动',
'memory.searchContext': '搜索上下文...',
'memory.noRecentActivity': '无最近活动',
'memory.reads': '读取',
'memory.edits': '编辑',
'memory.prompts': '提示',
'memory.nodeDetails': '节点详情',
'memory.heat': '热度',
'memory.associations': '关联',
'memory.type': '类型',
'memory.relatedNodes': '相关节点',
'memory.noAssociations': '未找到关联',
'memory.justNow': '刚刚',
'memory.minutesAgo': '分钟前',
'memory.hoursAgo': '小时前',
// Common
'common.cancel': '取消',
'common.create': '创建',