koishi-plugin-group-memory 1.1.0 → 1.1.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +10 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-group-memory",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "智能群聊记忆中间件:自动记录上下文,在@或回复时注入前情提要,支持时间窗口过滤与内容清洗",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -1,9 +1,9 @@
1
- const { Schema } = require('koishi'); // 引入 Schema
1
+ const { Schema } = require('koishi');
2
2
 
3
3
  exports.name = 'group-memory';
4
4
  exports.usage = '自动记录群聊上下文,并在用户@机器人或回复机器人时,将前情提要注入给 AI 插件';
5
5
 
6
- // --- 关键修改:使用 Schema 定义配置 ---
6
+ // --- 修复:移除所有可能导致错误的 UI 方法 ---
7
7
  exports.Config = Schema.object({
8
8
  // --- 记忆设置 ---
9
9
  maxContext: Schema.number()
@@ -41,21 +41,12 @@ exports.Config = Schema.object({
41
41
  .default(true)
42
42
  .description('是否移除图片/媒体占位符 (如 [图片])。'),
43
43
 
44
- prefixTemplate: Schema.string()
45
- .default((history) => {
46
- // Schema 不支持函数作为默认值,对于复杂模板,我们提供一个字符串示例
47
- // 用户可以在配置文件中手动编写复杂的 JS 函数
48
- return "【群聊前情提要】\n" +
49
- history.map(msg => `${msg.timeStr} ${msg.user}: ${msg.content}`).join('\n') +
50
- "\n---\n请结合以上上下文回答以下问题:";
51
- })
52
- .textarea()
53
- .rows(5)
54
- .description(
55
- '自定义前情提要的模板字符串。注意:网页配置不支持动态 JS 函数,' +
56
- '如果需要动态模板,可在配置文件中直接写函数。' +
57
- '可用变量: {history} (JSON 格式的历史记录数组)'
58
- ),
44
+ // prefixTemplate: Schema.string() // 这个配置项比较复杂,不适合用 Schema.string() 来定义
45
+ // .default(...)
46
+ // .textarea() // 导致错误
47
+ // .rows(5) // 导致错误
48
+ // ...
49
+ // 我们将其移除,让其成为一个纯粹的代码逻辑,默认值直接在 apply 函数中硬编码。
59
50
 
60
51
  // --- 调试 ---
61
52
  verbose: Schema.boolean()
@@ -154,9 +145,8 @@ exports.apply = (ctx, config) => {
154
145
 
155
146
  if (history.length === 0) return next();
156
147
 
157
- // 由于 Schema 无法在网页端处理函数,我们简化处理
158
- // 使用一个简单的模板字符串进行替换,或者直接使用默认逻辑
159
- // 更复杂的模板应该由用户在配置文件中定义函数来实现
148
+ // --- 修复:将 prefixTemplate 的逻辑移回 apply 函数内部 ---
149
+ // 由于 Schema 无法处理函数类型的配置,我们将模板逻辑放在这里
160
150
  const contextLines = history.map(msg => `${msg.timeStr} ${msg.user}: ${msg.content}`);
161
151
  const contextPrefix = `【群聊前情提要】\n${contextLines.join('\n')}\n---\n请结合以上上下文回答以下问题:`;
162
152