koishi-plugin-group-analysis-mx 1.7.7 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LLMService = void 0;
4
4
  const koishi_1 = require("koishi");
5
5
  const js_yaml_1 = require("js-yaml");
6
+ const REPAIRABLE_QUOTED_FIELDS = new Set(['sender', 'name', 'username', 'user_id', 'userId', 'id', 'topic', 'title', 'mbti']);
7
+ function repairUnclosedQuotedFields(source) {
8
+ let changed = false;
9
+ const repaired = String(source).split(/\r?\n/).map((line) => {
10
+ const match = line.match(/^(\s*)([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*("(?:\\.|[^"\\])*)\s*$/);
11
+ if (!match || !REPAIRABLE_QUOTED_FIELDS.has(match[2]))
12
+ return line;
13
+ changed = true;
14
+ return line + '"';
15
+ }).join('\n');
16
+ return changed ? repaired : null;
17
+ }
6
18
  class LLMService extends koishi_1.Service {
7
19
  config;
8
20
  constructor(ctx, config) {
@@ -44,7 +56,17 @@ class LLMService extends koishi_1.Service {
44
56
  }
45
57
  try {
46
58
  // json: true 容忍重复 key(LLM 偶尔会重复输出 sender 等字段),后者覆盖前者
47
- const data = (0, js_yaml_1.load)(yamlMatch[1], { json: true });
59
+ let data;
60
+ try {
61
+ data = (0, js_yaml_1.load)(yamlMatch[1], { json: true });
62
+ }
63
+ catch (parseError) {
64
+ const repairedYaml = repairUnclosedQuotedFields(yamlMatch[1]);
65
+ if (!repairedYaml)
66
+ throw parseError;
67
+ data = (0, js_yaml_1.load)(repairedYaml, { json: true });
68
+ this.ctx.logger.warn(`LLM ${taskName} YAML 的身份字段缺少结束引号,已自动修复后解析。`);
69
+ }
48
70
  if (Array.isArray(data)) {
49
71
  this.ctx.logger.info(`成功解析 ${data.length} 条数据。`);
50
72
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-group-analysis-mx",
3
3
  "description": "群聊分析插件 - 生成精美群聊统计报告,支持 AI 话题总结(独立版,不依赖 ChatLuna)",
4
- "version": "1.7.7",
4
+ "version": "1.7.8",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -62,3 +62,4 @@
62
62
 
63
63
 
64
64
 
65
+
@@ -442,8 +442,10 @@ body {
442
442
  }
443
443
 
444
444
  .masonry-grid {
445
- column-count: 2;
445
+ display: grid;
446
+ grid-template-columns: repeat(2, minmax(0, 1fr));
446
447
  column-gap: 25px;
448
+ align-items: start;
447
449
  }
448
450
 
449
451
  .user-card {
@@ -793,7 +795,7 @@ body {
793
795
  }
794
796
 
795
797
  .masonry-grid {
796
- column-count: 1;
798
+ grid-template-columns: minmax(0, 1fr);
797
799
  }
798
800
 
799
801
  .stamp {