koishi-plugin-satori-ai 1.2.8 → 1.2.9

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.
package/lib/game.d.ts CHANGED
@@ -9,7 +9,8 @@ export declare class Game {
9
9
  private availableGames;
10
10
  private context;
11
11
  private config;
12
- constructor(ctx: Context, cfg: Sat.Config);
12
+ private sat;
13
+ constructor(ctx: Context, cfg: Sat.Config, sat: Sat);
13
14
  private registerCommands;
14
15
  startGame(session: Session, gameName: string, args: string[]): Promise<"当前频道已经有游戏在进行中" | "没有这个游戏哦">;
15
16
  endGame(session: Session): Promise<string>;
@@ -8,6 +8,7 @@ export declare enum winFlag {
8
8
  }
9
9
  export interface goBangGameResult extends gameResult {
10
10
  win: winFlag;
11
+ level: number;
11
12
  }
12
13
  /**
13
14
  * 五子棋单局实现类,继承自 abstractGameSingleGame
package/lib/index.js CHANGED
@@ -135,8 +135,8 @@ function processPrompt(prompt) {
135
135
  return "";
136
136
  if (prompt.includes(":poke"))
137
137
  return "戳戳";
138
+ prompt = prompt.replace(/<[^>]*?avatar[^>]*>/g, "。回复:");
138
139
  prompt = prompt.replace(/<[^>]*?img[^>]*>/g, "[图片]");
139
- prompt = prompt.replace(/<[^>]*?avatar[^>]*>/g, "");
140
140
  prompt = prompt.replace(/<[^>]*?name="([^\"]*)"[^>]*>/g, (_, name) => `@${name}`);
141
141
  return prompt;
142
142
  }
@@ -498,7 +498,6 @@ var MemoryManager = class {
498
498
  if (response.error)
499
499
  return;
500
500
  this.updateChannelMemory(session, prompt, config, response.content);
501
- prompt = prompt.replace("我", session.username);
502
501
  const date = ` (对话日期和时间:${(/* @__PURE__ */ new Date()).toLocaleString()})`;
503
502
  const userFavourbility = (await getUser(this.ctx, session.userId)).favorability;
504
503
  if (this.shouldRemember(prompt, userFavourbility)) {
@@ -1162,7 +1161,14 @@ var UserPortraitManager = class {
1162
1161
  if (!fs5.existsSync(memoryPath))
1163
1162
  return [];
1164
1163
  const memoryContent = JSON.parse(fs5.readFileSync(memoryPath, "utf-8"));
1165
- const validEntries = memoryContent.filter((entry) => entry.role !== "user").map((entry) => {
1164
+ const replacedContent = memoryContent.map((entry) => {
1165
+ return {
1166
+ ...entry,
1167
+ content: entry.content.replace(user.usersname, "我")
1168
+ };
1169
+ });
1170
+ fs5.writeFileSync(memoryPath, JSON.stringify(replacedContent, null, 2));
1171
+ const validEntries = replacedContent.filter((entry) => entry.role !== "user").map((entry) => {
1166
1172
  const timeMatch = entry.role.match(/对话日期和时间:(\d{4}\/\d{1,2}\/\d{1,2} \d{2}:\d{2}:\d{2})/);
1167
1173
  if (!timeMatch)
1168
1174
  return null;
@@ -1417,12 +1423,12 @@ var SAT = class extends Sat {
1417
1423
  const favorabilityBlock = await this.checkFavorabilityBlock(session);
1418
1424
  if (favorabilityBlock)
1419
1425
  return favorabilityBlock;
1420
- const preCheckResult = this.performPreChecks(session, prompt);
1426
+ const preCheckResult = this.performPreChecks(session, processedPrompt);
1421
1427
  if (preCheckResult)
1422
1428
  return preCheckResult;
1423
1429
  const channelId = this.config.enable_self_memory ? session.userId : session.channelId;
1424
1430
  const recentDialogues = this.memoryManager.getChannelMemory(channelId).slice(-10);
1425
- const duplicateCheck = await this.checkDuplicateDialogue(session, prompt, recentDialogues, user);
1431
+ const duplicateCheck = await this.checkDuplicateDialogue(session, processedPrompt, recentDialogues, user);
1426
1432
  if (duplicateCheck)
1427
1433
  return duplicateCheck;
1428
1434
  const fixedResponse = await this.handleFixedDialoguesCheck(session, user, processedPrompt);
@@ -1579,7 +1585,7 @@ var SAT = class extends Sat {
1579
1585
  }
1580
1586
  const userMemory = this.memoryManager.getChannelContext(this.config.personal_memory ? session.userId : session.channelId);
1581
1587
  messages.push(...userMemory);
1582
- if (this.config.input_prompt && messages.length > 2) {
1588
+ if (this.config.input_prompt && messages.length > 1) {
1583
1589
  messages.push({ role: "user", content: "system:" + this.config.input_prompt });
1584
1590
  messages.push({ role: "assistant", content: "好的,我会按您的要求进行回复。" });
1585
1591
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-satori-ai",
3
3
  "description": "基于 Satori 适配器的智能对话插件,具备用户画像、长期记忆、常识管理和好感度系统",
4
- "version": "1.2.8",
4
+ "version": "1.2.9",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "types": "lib/index.d.ts",