tavern-harness 0.2.3 → 0.2.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  > 本文件由 `scripts/changelog.mjs` 从 `changelog/v*.md` 生成,请勿手动编辑。
4
4
  > 版本对比链接见文末;源文件位于仓库 `changelog/` 目录。
5
5
 
6
+ ## [0.2.4] - 2026-11-22
7
+
8
+ ### 中文
9
+
10
+ #### 修复
11
+
12
+ - 修复通过 `/nsfw` 或长按发送键注入破甲指令后,重新生成该回复时不再注入破甲指令的问题;现在重新生成会读取当前会话最新的破甲指令并临时注入
13
+
14
+ ### English
15
+
16
+ #### Fixed
17
+
18
+ - Fixed regenerating a reply that was sent with `/nsfw` or hold-to-charge losing the armor-breaking injection; regeneration now applies the latest armor-breaking instruction configured for the conversation
19
+
6
20
  ## [0.2.3] - 2026-11-21
7
21
 
8
22
  ### 中文
@@ -1141,6 +1155,7 @@
1141
1155
  - Vite + React + Zustand + Dexie stack with browser-side local persistence
1142
1156
 
1143
1157
  <!-- 链接定义 -->
1158
+ [0.2.4]: https://github.com/Rannichan/Tavern-Harness/compare/v0.2.3...v0.2.4
1144
1159
  [0.2.3]: https://github.com/Rannichan/Tavern-Harness/compare/v0.2.2...v0.2.3
1145
1160
  [0.2.2]: https://github.com/Rannichan/Tavern-Harness/compare/v0.2.1...v0.2.2
1146
1161
  [0.2.1]: https://github.com/Rannichan/Tavern-Harness/compare/v0.2.0...v0.2.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tavern-harness",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Tavern Harness — 酒馆模式下的本地 AI Agent 助手(MyAgent-Android 的 Web 复刻)",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1,7 +1,31 @@
1
1
  {
2
- "latest": "0.2.3",
2
+ "latest": "0.2.4",
3
3
  "repo": "https://github.com/Rannichan/Tavern-Harness",
4
4
  "entries": [
5
+ {
6
+ "version": "0.2.4",
7
+ "date": "2026-11-22",
8
+ "breaking": false,
9
+ "compare": "v0.2.3...v0.2.4",
10
+ "groups": {
11
+ "zh-CN": [
12
+ {
13
+ "kind": "fixed",
14
+ "items": [
15
+ "修复通过 `/nsfw` 或长按发送键注入破甲指令后,重新生成该回复时不再注入破甲指令的问题;现在重新生成会读取当前会话最新的破甲指令并临时注入"
16
+ ]
17
+ }
18
+ ],
19
+ "en": [
20
+ {
21
+ "kind": "fixed",
22
+ "items": [
23
+ "Fixed regenerating a reply that was sent with `/nsfw` or hold-to-charge losing the armor-breaking injection; regeneration now applies the latest armor-breaking instruction configured for the conversation"
24
+ ]
25
+ }
26
+ ]
27
+ }
28
+ },
5
29
  {
6
30
  "version": "0.2.3",
7
31
  "date": "2026-11-21",
@@ -776,6 +776,9 @@ export const useStore = create<AppState>((set, get) => ({
776
776
  // 以目标消息的时间戳为切断点:删除它及之后的所有消息(通常为其附属 tool 结果),
777
777
  // 随后重新生成该条回复(重新生成 = 旧回复连同后续内容一起被新回复替换)
778
778
  const messages = snapshotMessages;
779
+ const forcePerformanceGuidance =
780
+ get().settings?.nsfwMode === true &&
781
+ hasPerformanceGuidanceMarkerForReply(messages, message);
779
782
  const toDelete = messages.filter((m) => m.timestamp >= message.timestamp);
780
783
  await deleteContextCompressionsFrom(sessionId, message.timestamp);
781
784
  await db.messages.bulkDelete(toDelete.map((m) => m.id!));
@@ -791,8 +794,11 @@ export const useStore = create<AppState>((set, get) => ({
791
794
  contextTokensLoopIndex: null,
792
795
  });
793
796
 
797
+ // 重新生成始终读取当前会话配置,因此即使原回复生成后修改过破甲指令,
798
+ // 本次临时注入也使用点击重新生成时的最新文本。
799
+ const regenerationSession = (await db.sessions.get(sessionId)) ?? session;
794
800
  let result: TurnResult;
795
- if (session.mode === 'GROUP') {
801
+ if (regenerationSession.mode === 'GROUP') {
796
802
  // 群聊:把被重生成 assistant 的发言人重新置顶(联动发言队列)。
797
803
  // 若该条发言是当前循环某位成员(未知 speakerParticipantId,如收尾回复),
798
804
  // 无法映射到具体成员,则直接按当前队列继续。
@@ -802,9 +808,9 @@ export const useStore = create<AppState>((set, get) => ({
802
808
  .filter((p) => p.participantId === message.speakerParticipantId)
803
809
  .first()) ?? null
804
810
  : null;
805
- result = await continueRegeneratedGroupLoop(session, message, participant);
811
+ result = await continueRegeneratedGroupLoop(regenerationSession, message, participant, forcePerformanceGuidance);
806
812
  } else {
807
- result = await runConversationLoop(session);
813
+ result = await runConversationLoop(regenerationSession, forcePerformanceGuidance);
808
814
  }
809
815
 
810
816
  if (result === 'failed') {
@@ -1619,10 +1625,13 @@ async function handleMagicCommand(session: ChatSession, cmd: string): Promise<vo
1619
1625
  }
1620
1626
  }
1621
1627
 
1628
+ function isBeforeMessage(candidate: ChatMessage, target: ChatMessage): boolean {
1629
+ return candidate.timestamp < target.timestamp ||
1630
+ (candidate.timestamp === target.timestamp && candidate.id! < target.id!);
1631
+ }
1632
+
1622
1633
  function hasPerformanceGuidanceMarkerForUser(messages: ChatMessage[], userMessage: ChatMessage): boolean {
1623
- const earlier = messages
1624
- .filter((message) => message.timestamp < userMessage.timestamp || (message.timestamp === userMessage.timestamp && message.id! < userMessage.id!))
1625
- .reverse();
1634
+ const earlier = messages.filter((message) => isBeforeMessage(message, userMessage)).reverse();
1626
1635
  const previousUserIndex = earlier.findIndex((message) => message.role === 'user');
1627
1636
  const relevant = previousUserIndex < 0 ? earlier : earlier.slice(0, previousUserIndex);
1628
1637
  return relevant.some(
@@ -1630,6 +1639,13 @@ function hasPerformanceGuidanceMarkerForUser(messages: ChatMessage[], userMessag
1630
1639
  );
1631
1640
  }
1632
1641
 
1642
+ function hasPerformanceGuidanceMarkerForReply(messages: ChatMessage[], reply: ChatMessage): boolean {
1643
+ const sourceUser = messages
1644
+ .filter((message) => message.role === 'user' && isBeforeMessage(message, reply))
1645
+ .at(-1);
1646
+ return sourceUser != null && hasPerformanceGuidanceMarkerForUser(messages, sourceUser);
1647
+ }
1648
+
1633
1649
  /** 对话主循环:NPC / STANDARD 直接回复;GROUP 依队列轮转。
1634
1650
  * 返回该轮生成结果(供「重新生成」失败回退判断)。 */
1635
1651
  async function runConversationLoop(session: ChatSession, forcePerformanceGuidance = false): Promise<TurnResult> {
@@ -2796,7 +2812,8 @@ async function continueGroupConversation(sessionId: number, forcePerformanceGuid
2796
2812
  async function continueRegeneratedGroupLoop(
2797
2813
  session: ChatSession,
2798
2814
  editedMessage: ChatMessage,
2799
- editedSpeaker: ChatParticipant | null
2815
+ editedSpeaker: ChatParticipant | null,
2816
+ forcePerformanceGuidance = false,
2800
2817
  ): Promise<TurnResult> {
2801
2818
  const sessionId = session.id!;
2802
2819
  const participants = await db.participants.where('sessionId').equals(sessionId).toArray();
@@ -2804,14 +2821,14 @@ async function continueRegeneratedGroupLoop(
2804
2821
  if (speakerParticipantId == null) {
2805
2822
  // 发言者不可映射 → 仅刷新队列并照常续跑
2806
2823
  await refreshQueueAndSave(sessionId);
2807
- return continueGroupConversation(sessionId);
2824
+ return continueGroupConversation(sessionId, forcePerformanceGuidance);
2808
2825
  }
2809
2826
  const { queue, loopIndex, loopStarted } = refreshQueue(session, participants);
2810
2827
  // 编辑后:该角色“重讲一遍” → 置顶队列,联动发言队列面板与下一轮顺序
2811
2828
  const nextQueue = requeueSpeaker(queue, speakerParticipantId);
2812
2829
  await persistQueue(sessionId, nextQueue, loopIndex, loopStarted);
2813
2830
  await useStore.getState().refreshLiveQueue(sessionId);
2814
- return continueGroupConversation(sessionId);
2831
+ return continueGroupConversation(sessionId, forcePerformanceGuidance);
2815
2832
  }
2816
2833
 
2817
2834
  /** 工具确认在 YOLO 模式下自动批准;执行限额仍挂起等待用户应答。 */