11 Commits

Author SHA1 Message Date
31a21d5364 fix: 修复审查发现的多个问题并补全开发环境
- 修复 MaxPreview=0 仍被覆盖为默认值的 bug
- 修复 API Endpoint 自动补全逻辑(避免 /v1/v1/chat/completions)
- 为 AI 配置与匹配状态字段增加并发锁
- AI 增强未匹配行改为按索引跟踪,避免重复行误判
- 无时间列时 AI 匹配 B 表行数可配置并增加截断警告
- 导出时防御参差不齐行导致的数组越界 panic
- Excel 读取时对单元格统一 TrimSpace
- 删除未使用的 minInt 函数
- 修复 wails.json 开发服务器地址为 http://localhost:5173
- 重新生成 Wails 前端绑定
- 新增 ai_test.go / export_test.go 单元测试
2026-06-23 20:55:32 +00:00
sakuradairong
2b17760fbd Merge remote changes, split app.go, remove V1 dead code, fix AICache (#2)
- Merge remote improvements: generic AI API, row-level cache,
  CSV export, matchPrep, prompt truncation, O(1) cache index
- Split app.go (1645 -> 5 files: app.go, cache.go, ai.go,
  matcher.go, export.go)
- Remove V1 dead code: 6 methods, 4 helpers, ~300 lines
- Fix AICache 3 bugs: TOCTOU saveToFile, silent loadFromFile,
  full-sort put
- Extract 8 named constants (threshold, time window, batch size...)
- Frontend: isRunning guard, buildMatchConfig dedup, CSS variables
- Upgrade Go to 1.24.0
2026-06-05 14:46:55 +08:00
sakuradairong
40745f5632 release: v1.1.0
移除 V1 死代码(6 个导出方法、4 个内部函数、~300 行),
新增 cache.go/ai.go/matcher.go/export.go 拆分 app.go(原 1645 行),
修复 AICache 3 个并发 bug(TOCTOU、反序列化、全排序),
提取 8 个命名常量,前端添加 isRunning 守卫和 CSS 变量。
Go 升级至 1.24.0。
2026-06-05 14:40:55 +08:00
RainySY
080ec17db8 fix: prevent hang on re-match with guards and timeout
Frontend:
- Add loading guard to AI button disabled state
- Add re-entry guard at top of startMatching and startAIEnhance

Backend:
- Add maxMatchDuration (10 min) with periodic timeout checks
- Check timeout in outer A-loop (every row) and inner B-loop (every 500 iter)
- Reduce HTTP client timeout from 60s to 30s for API calls
2026-05-20 15:03:27 +08:00
RainySY
8ded79f6ce fix: auto-append /v1/chat/completions to AI API endpoint
When user enters a base URL like http://localhost:8080, auto-normalize it
to http://localhost:8080/v1/chat/completions. Full URLs with /chat/completions
suffix are left unchanged. Also update frontend placeholder text.
2026-05-20 14:41:38 +08:00
RainySY
6f9ffc59f3 feat: support any OpenAI-compatible AI API
Backend:
- Add apiEndpoint / apiModel fields to App struct (configurable, with Deepseek defaults)
- New SetAIConfig(endpoint, model, key) unified config method
- New SetAPIKey(key) for key-only updates
- GetAIStatus() returns { ready, endpoint, model }
- callDeepseekAPI → callAIAPI with configurable endpoint and model
- Remove hardcoded Deepseek URL/model; defaults remain as fallback

Frontend:
- Replace Deepseek-specific state with generic AI config (endpoint / model / key)
- Add endpoint URL and model name input fields
- saveApiKey → saveApiConfig using SetAIConfig
- onMounted restores full AI config via GetAIStatus
- Rename all user-facing 'Deepseek' labels to 'AI / AI API'

Now supports: Deepseek, OpenAI, Ollama, vLLM, or any OpenAI-compatible endpoint.
2026-05-20 14:33:10 +08:00
RainySY
b5a91cb115 perf: optimize hot path & reorganize project config
Backend (app.go):
- AICache: replace linear scan with map-based O(1) lookup (get/getRow/put/putRow)
- runMatchOnData: pre-compute B-column cleaned values, parsed times, extract values
  to eliminate O(n*m) regex/time-parse from inner loop
- calcSimilarity: eliminate double rune conversion (levenshteinDistance now takes []rune)
- Add similarityFromCleaned to skip redundant regex step in hot path
- Fix corrupted bare 'n' literal causing build failure
- Move saveToFile out of inner match loop (was called per item)
- dataMu: Mutex -> RWMutex (exportHeaders/ExportResults use RLock)
- buildGenericAIPrompt: fix truncation check order (check after write)

Project:
- .gitignore: deduplicate & tighten rules; track package-lock.json and .vscode/*
- Clean up stale root binary (data-matcher.exe)
2026-05-20 14:16:13 +08:00
RainySY
40c3966e9a fix: 修复代码审查全部18项问题,重构导出与匹配引擎
A级(严重):
- ExportResults 支持 CSV 格式导出和 IncludeHeader 配置,使用实际表头名
- RunMatchWithAI 消除重复文件读取,提取 runMatchOnData() 内部函数
- AI 缓存文件权限收紧至 0600

B级(中等):
- 移除废弃代码约400行 (MonthlyReport/DailyReport/StartMatching/DeepseekEnhanceMatching)
- 替换自定义 parseCSVLine 为标准 encoding/csv
- GetAICacheInfo 返回命名结构体 AICacheInfo
- 时间差排序改为数值比较
- App.vue 提取 buildMatchConfig() 工厂函数消除配置重复
- AllMatches=false 时命中 1.0 相似度可提前结束 B 表循环

C级(轻微):
- 魔法数字提取为命名常量
- main.go 替换 println 为 log.Fatalf
- 清理未使用变量

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 14:27:15 +08:00
RainySY
b3ec20fd77 fix: 修复代码审查发现的8项问题
- P0: 新增 RunMatchWithAI (配置驱动) 替代 DeepseekEnhanceMatching 的硬编码阈值
- P0: 前端 startAIEnhance 使用 fileAPath/fileBPath 替代未赋值的 monthlyPath/dailyPath
- P1: reasonMap 移至批循环外仅构建一次; CSV 转义双引号支持; twoHours 变量重命名
- P2: 删除 rowAndScore; calcSimilarity 实现 CaseSensitive; AI 解析失败增加日志
- 时间窗口过滤改用用户配置的 windowDuration 替代硬编码 3h; 旧函数标注弃用
2026-05-07 02:09:29 +08:00
RainySY
d31c3e46f5 feat: AI 缓存系统 + 优化 prompt 构建
- 新增 AICache 持久化缓存(SHA256 键,存储于临时文件)
- callDeepseekAPI 自动查缓存,命中跳过 API 调用
- buildAIPrompt 按时间窗口过滤日报记录,减少 token 消耗
- AI 结果匹配改用 map 查找替代 O(n²) 遍历
- 前端添加缓存状态显示和「清除缓存」按钮
- 新增 ClearAICache / GetAICacheInfo 绑定方法
2026-05-07 01:26:44 +08:00
RainySY
2cef098632 feat: Initialize data-matcher project with Wails framework
- Added frontend runtime JavaScript functions for logging, window management, and notifications.
- Created Go module with dependencies for Wails and Excel processing.
- Implemented main application entry point with embedded frontend assets.
- Configured Wails application settings in wails.json.

Co-authored-by: Copilot <copilot@github.com>
2026-05-07 01:11:05 +08:00