@starlight-ai/discord-waifus 1.5.135 → 1.5.136

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.
@@ -1,6 +1,7 @@
1
1
  import { readFile, readdir } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { ensureDataLayout } from "../config/layout.js";
4
+ import { defaultWaifuPromptLayout } from "../shared/schemas/domain.js";
4
5
  import { atomicWriteJson } from "../storage/atomic.js";
5
6
  export async function runMigrations(dataRoot) {
6
7
  await ensureDataLayout(dataRoot);
@@ -22,6 +23,10 @@ export async function runMigrations(dataRoot) {
22
23
  if (await archiveMemoriesWithUnknownWaifus(dataRoot)) {
23
24
  applied.push("archive-memories-with-unknown-waifus");
24
25
  }
26
+ const layoutsMigrated = await migrateWaifuPromptSections(dataRoot);
27
+ if (layoutsMigrated > 0) {
28
+ applied.push(`migrate-waifu-prompt-layout-${layoutsMigrated}`);
29
+ }
25
30
  return { applied };
26
31
  }
27
32
  async function readJsonOrUndefined(filePath) {
@@ -284,6 +289,71 @@ async function migrateSessionFiles(dataRoot) {
284
289
  }
285
290
  return count;
286
291
  }
292
+ // Legacy waifus stored a flat boolean `promptSections` toggle set. Convert each into the new
293
+ // ordered `promptLayout` tree, preserving the user's on/off choices by disabling the matching
294
+ // blocks on top of the default arrangement. Always-on and conditional blocks stay enabled.
295
+ const LEGACY_PROMPT_SECTION_TO_BLOCK = {
296
+ directorNotes: "directorNotes",
297
+ hardRules: "hardRules",
298
+ mentionPolicy: "mentionPolicy",
299
+ replyTargeting: "replyTargeting",
300
+ environmentInstructions: "environment",
301
+ inputFormat: "contextStructure",
302
+ styleConstraints: "styleConstraints",
303
+ personality: "personalityReminder"
304
+ };
305
+ function setBlockEnabled(layout, blockId, enabled) {
306
+ const visit = (nodes) => {
307
+ for (const node of nodes) {
308
+ if (node.kind === "block") {
309
+ if (node.blockId === blockId)
310
+ node.enabled = enabled;
311
+ }
312
+ else {
313
+ for (const child of node.children) {
314
+ if (child.blockId === blockId)
315
+ child.enabled = enabled;
316
+ }
317
+ }
318
+ }
319
+ };
320
+ visit(layout.top);
321
+ visit(layout.mid);
322
+ visit(layout.trailing);
323
+ }
324
+ async function migrateWaifuPromptSections(dataRoot) {
325
+ const waifusRoot = path.join(dataRoot, "user", "waifus");
326
+ let entries;
327
+ try {
328
+ entries = await readdir(waifusRoot);
329
+ }
330
+ catch (error) {
331
+ if (error.code === "ENOENT")
332
+ return 0;
333
+ throw error;
334
+ }
335
+ let count = 0;
336
+ for (const entry of entries) {
337
+ const filePath = path.join(waifusRoot, entry, "waifu.json");
338
+ const data = await readJsonOrUndefined(filePath);
339
+ if (!isObject(data))
340
+ continue;
341
+ const legacy = data.promptSections;
342
+ if (!isObject(legacy))
343
+ continue; // already migrated or never had the legacy field
344
+ const layout = defaultWaifuPromptLayout();
345
+ for (const [legacyKey, blockId] of Object.entries(LEGACY_PROMPT_SECTION_TO_BLOCK)) {
346
+ if (legacy[legacyKey] === false) {
347
+ setBlockEnabled(layout, blockId, false);
348
+ }
349
+ }
350
+ data.promptLayout = layout;
351
+ delete data.promptSections;
352
+ await atomicWriteJson(filePath, data);
353
+ count += 1;
354
+ }
355
+ return count;
356
+ }
287
357
  async function migrateLegacyMemories(dataRoot) {
288
358
  const filePath = path.join(dataRoot, "user", "memories.json");
289
359
  const data = await readJsonOrUndefined(filePath);
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/backend/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB;IAClD,MAAM,gBAAgB,CAAC,QAAQ,CAAC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 -0,0 +1,28 @@
1
+ import type { WaifuPromptLayout } from "../shared/schemas/domain.js";
2
+ export type PromptBlockContext = {
3
+ waifuTag: string;
4
+ displayName: string;
5
+ personalityContent: string;
6
+ scheduleContent: string;
7
+ toolUseInstructions: string | undefined;
8
+ activeParticipantDisplayNames: string[];
9
+ emojiList: string;
10
+ memoryLines: string[];
11
+ currentlyDoing: string | undefined;
12
+ sceneDirection: string | undefined;
13
+ };
14
+ export type WaifuPromptSection = "top" | "mid" | "trailing";
15
+ export type WaifuPromptBlockDef = {
16
+ id: string;
17
+ defaultSection: WaifuPromptSection;
18
+ render: (ctx: PromptBlockContext) => string | undefined;
19
+ };
20
+ export declare const WAIFU_PROMPT_BLOCKS: WaifuPromptBlockDef[];
21
+ export declare function promptTagName(value: string): string;
22
+ export declare function resolveGroupTag(tag: string, waifuTag: string): string;
23
+ export declare function assembleWaifuPrompt(layout: WaifuPromptLayout, ctx: PromptBlockContext): {
24
+ systemPrompt: string;
25
+ midSystemBlock: string;
26
+ trailingSystemBlock: string;
27
+ };
28
+ export declare function reconcileWaifuPromptLayout(layout: WaifuPromptLayout): WaifuPromptLayout;
@@ -0,0 +1,231 @@
1
+ // --- Fixed block wording (copied verbatim from the historical buildWaifuPromptParts) ----------
2
+ const INPUT_FORMAT = [
3
+ "Each incoming message in this conversation arrives in a chat-transcript shape so you can read Discord context:",
4
+ "An optional `> Author: preview` line appears first when the message is replying to an earlier one (Discord blockquote shape). The next line is `DisplayName: <body>` (the body may continue on additional lines). Optional `[attachments: Nx image]` and `[image_text: ...]` lines may follow, one per image with extracted text.",
5
+ "The `> Author: ...` quote, the `DisplayName:` prefix, and any bracketed lines are framing only. They are not part of what the speaker actually wrote, and they are not how Discord messages look."
6
+ ].join("\n");
7
+ const REPLY_TARGETING = [
8
+ "To reply to one specific earlier message, you may start your reply with a single `> Author: text-of-that-message` line. Copy the message text as closely as you can (small differences are fine; the runtime fuzzy-matches it). Put your actual reply on the next line.",
9
+ "The `>` quote line is not sent to Discord; it only tells the runtime which message your reply targets.",
10
+ "Use this instead of pinging when you want to address one specific earlier message. Otherwise omit the quote entirely and just write your reply.",
11
+ "Quote example - to reply specifically to Kevin's earlier `what's the weather like?` message, write:\n > Kevin: what's the weather like?\n sunny and warm\nThe runtime consumes the `> Kevin: ...` line to set Discord's reply target; only `sunny and warm` is sent."
12
+ ].join("\n");
13
+ const MENTION_POLICY = [
14
+ "To ping a user, write <@DisplayName> - where `DisplayName` is copied verbatim from the `DisplayName:` prefix on one of their messages. Example: a message that starts with `Kevin: hey` is pinged as <@Kevin>.",
15
+ "Do not ping a user who is already active in the recent chat or who just spoke. Mention their display name in plain text instead.",
16
+ "Only ping when you are reviving an older missed message, pulling back someone who has gone quiet, or a scene_direction explicitly asks for a ping."
17
+ ].join("\n");
18
+ const STYLE_CONSTRAINTS = [
19
+ "Write exactly one short phrase or one very short sentence, usually under 12 words.",
20
+ "Never write a second sentence.",
21
+ "This length rule overrides your persona, reply_style, and scene_direction. Even when asked for a longer or more thoughtful reply, compress it to one tiny conversational beat.",
22
+ "Avoid stacked clauses, multi-line replies, setup-plus-punchline chains, and explanations. A sharp fragment is usually stronger than a complete mini speech."
23
+ ].join("\n");
24
+ const HARD_RULES = [
25
+ "Your reply is the raw message body that will be sent verbatim to Discord.",
26
+ "Your turn is exactly one Discord message body, never a transcript.",
27
+ "Do not write `Name: ...` or `DisplayName: ...` lines for any character, including yourself and every other waifu in the channel.",
28
+ "Do not draft another waifu's reply. If you find yourself doing that, stop and write only your own message.",
29
+ "Do not include bracketed metadata tags: no `[attachments: ...]`, no `[image_text: ...]`, no `[replying to: ...]`, no `[timestamp: ...]`, no `[reactions: ...]`, no `[index: ...]`, no `[scene_direction: ...]`, and no other `[tag: value]` constructions.",
30
+ "Do not begin with your own display name followed by a colon. Other than the optional leading `> Author: ...` reply-targeting line, begin with the first word you are actually saying.",
31
+ "Do not echo or paraphrase any prior message's bracketed framing tags.",
32
+ "Do not output physical actions, roleplay narration, or stage directions. No asterisks-wrapped actions like *smiles* or *waves*, no parenthetical stage notes like (hugs them), and no bracketed cues like [walks over].",
33
+ "The optional leading `> Author: ...` reply-targeting line is the only allowed prefix exception.",
34
+ "Never use raw Discord IDs for pings.",
35
+ "Use only listed server emojis."
36
+ ].join("\n");
37
+ const ENVIRONMENT_RULES = [
38
+ "You are chatting in a live Discord text channel — this is a real chat room with real users, not a roleplay scene, story, or chat fiction.",
39
+ "Write one Discord-safe message per turn.",
40
+ "Reply with only what you would actually type into a chat box — no narration, no meta commentary, no describing yourself in the third person."
41
+ ].join("\n");
42
+ const DIRECTOR_NOTES = [
43
+ "Keep your reply short.",
44
+ "Do not repeat what the previous waifu just said.",
45
+ "Do not repeat a person's name when recent context already makes the target clear.",
46
+ "To pull a quiet person back in, use their <@Name> tag instead of repeating their name; do not tag them again if anyone already tagged them recently."
47
+ ].join("\n");
48
+ // --- Block registry ----------------------------------------------------------------------------
49
+ export const WAIFU_PROMPT_BLOCKS = [
50
+ {
51
+ id: "identity",
52
+ defaultSection: "top",
53
+ render: (ctx) => `<${ctx.waifuTag}_identity>\nYou are acting as ${ctx.displayName} in a discord server together with real people and other waifus\n</${ctx.waifuTag}_identity>`
54
+ },
55
+ {
56
+ id: "personality",
57
+ defaultSection: "top",
58
+ render: (ctx) => `<${ctx.waifuTag}_personality>\n${ctx.personalityContent}\n</${ctx.waifuTag}_personality>`
59
+ },
60
+ {
61
+ id: "schedule",
62
+ defaultSection: "top",
63
+ render: (ctx) => `<${ctx.waifuTag}_shedule>\n${ctx.scheduleContent}\n</${ctx.waifuTag}_shedule>`
64
+ },
65
+ {
66
+ id: "contextStructure",
67
+ defaultSection: "top",
68
+ render: () => `<context_message_structure>\n${INPUT_FORMAT}\n</context_message_structure>`
69
+ },
70
+ {
71
+ id: "environment",
72
+ defaultSection: "top",
73
+ render: () => `<environment_instructions>\n${ENVIRONMENT_RULES}\n</environment_instructions>`
74
+ },
75
+ {
76
+ id: "replyTargeting",
77
+ defaultSection: "top",
78
+ render: () => `<replying_to_message>\n${REPLY_TARGETING}\n</replying_to_message>`
79
+ },
80
+ {
81
+ id: "mentionPolicy",
82
+ defaultSection: "top",
83
+ render: () => `<mention_policy>\n${MENTION_POLICY}\n</mention_policy>`
84
+ },
85
+ {
86
+ id: "styleConstraints",
87
+ defaultSection: "top",
88
+ render: () => `<style_constraints>\n${STYLE_CONSTRAINTS}\n</style_constraints>`
89
+ },
90
+ {
91
+ id: "hardRules",
92
+ defaultSection: "top",
93
+ render: () => `<hard_rules>\n${HARD_RULES}\n</hard_rules>`
94
+ },
95
+ {
96
+ id: "toolUse",
97
+ defaultSection: "top",
98
+ // Content is gated upstream by waifu.tools.toolUse / model.supportsTools / active server
99
+ // tools; when there is nothing to say, toolUseInstructions is undefined and the block drops.
100
+ render: (ctx) => (ctx.toolUseInstructions ? `<tool_use>\n${ctx.toolUseInstructions}\n</tool_use>` : undefined)
101
+ },
102
+ {
103
+ id: "directorNotes",
104
+ defaultSection: "mid",
105
+ render: () => `<director_notes>\n${DIRECTOR_NOTES}\n</director_notes>`
106
+ },
107
+ {
108
+ id: "activeParticipants",
109
+ defaultSection: "mid",
110
+ render: (ctx) => `<active_chat_participants>\n${ctx.activeParticipantDisplayNames.length
111
+ ? ctx.activeParticipantDisplayNames.map((displayName) => `- ${displayName}`).join("\n")
112
+ : "(none)"}\n</active_chat_participants>`
113
+ },
114
+ {
115
+ id: "serverEmojis",
116
+ defaultSection: "mid",
117
+ render: (ctx) => `<server_emojis>\n${ctx.emojiList || "(none cached)"}\n</server_emojis>`
118
+ },
119
+ {
120
+ id: "relevantMemories",
121
+ defaultSection: "trailing",
122
+ render: (ctx) => ctx.memoryLines.length
123
+ ? `<${ctx.waifuTag}_relevant_memories>\n${ctx.memoryLines.join("\n")}\n</${ctx.waifuTag}_relevant_memories>`
124
+ : undefined
125
+ },
126
+ {
127
+ // The optional trailing personality reminder. Distinct id from `personality` so each layout
128
+ // node has exactly one home even though both render the same content.
129
+ id: "personalityReminder",
130
+ defaultSection: "trailing",
131
+ render: (ctx) => `<${ctx.waifuTag}_personality>\n${ctx.personalityContent}\n</${ctx.waifuTag}_personality>`
132
+ },
133
+ {
134
+ id: "currentlyDoing",
135
+ defaultSection: "trailing",
136
+ render: (ctx) => (ctx.currentlyDoing ? `<currently_doing>${ctx.currentlyDoing}</currently_doing>` : undefined)
137
+ },
138
+ {
139
+ id: "sceneDirection",
140
+ defaultSection: "trailing",
141
+ render: (ctx) => (ctx.sceneDirection ? `<scene_direction>${ctx.sceneDirection}</scene_direction>` : undefined)
142
+ }
143
+ ];
144
+ const BLOCK_BY_ID = new Map(WAIFU_PROMPT_BLOCKS.map((block) => [block.id, block]));
145
+ // --- Tag helpers -------------------------------------------------------------------------------
146
+ // Normalize an arbitrary string into a safe XML-ish tag name. Shared by the waifu tag and by
147
+ // user-created group tags so both follow the same rules.
148
+ export function promptTagName(value) {
149
+ const normalized = value
150
+ .trim()
151
+ .toLowerCase()
152
+ .replace(/[^a-z0-9_-]+/g, "_")
153
+ .replace(/^_+|_+$/g, "");
154
+ return /^[a-z]/.test(normalized) ? normalized : `waifu_${normalized || "unknown"}`;
155
+ }
156
+ // Resolve a group's stored tag template (which may contain the `{name}` token) into the final
157
+ // sanitized tag for a given waifu.
158
+ export function resolveGroupTag(tag, waifuTag) {
159
+ return promptTagName(tag.replace(/\{name\}/g, waifuTag));
160
+ }
161
+ // --- Assembly ----------------------------------------------------------------------------------
162
+ function renderBlock(blockId, ctx) {
163
+ return BLOCK_BY_ID.get(blockId)?.render(ctx);
164
+ }
165
+ function renderNode(node, ctx) {
166
+ if (!node.enabled)
167
+ return undefined;
168
+ if (node.kind === "block") {
169
+ return renderBlock(node.blockId, ctx);
170
+ }
171
+ const childParts = [];
172
+ for (const child of node.children) {
173
+ if (!child.enabled)
174
+ continue;
175
+ const out = renderBlock(child.blockId, ctx);
176
+ if (out)
177
+ childParts.push(out);
178
+ }
179
+ if (childParts.length === 0)
180
+ return undefined;
181
+ const tag = resolveGroupTag(node.tag, ctx.waifuTag);
182
+ return `<${tag}>\n${childParts.join("\n")}\n</${tag}>`;
183
+ }
184
+ function renderSection(nodes, ctx) {
185
+ const parts = [];
186
+ for (const node of nodes) {
187
+ const out = renderNode(node, ctx);
188
+ if (out)
189
+ parts.push(out);
190
+ }
191
+ return parts.join("\n");
192
+ }
193
+ // Walk the layout and build the three message-array strings. The slot→string mapping
194
+ // (top→systemPrompt, mid→midSystemBlock, trailing→trailingSystemBlock) is fixed; only the
195
+ // composition of each is data-driven.
196
+ export function assembleWaifuPrompt(layout, ctx) {
197
+ return {
198
+ systemPrompt: renderSection(layout.top, ctx),
199
+ midSystemBlock: renderSection(layout.mid, ctx),
200
+ trailingSystemBlock: renderSection(layout.trailing, ctx)
201
+ };
202
+ }
203
+ // Append any registry block missing from the stored layout to its default section (disabled), so
204
+ // that adding a new block to the registry later never makes it invisible to existing waifus.
205
+ export function reconcileWaifuPromptLayout(layout) {
206
+ const present = new Set();
207
+ const collect = (nodes) => {
208
+ for (const node of nodes) {
209
+ if (node.kind === "block")
210
+ present.add(node.blockId);
211
+ else
212
+ for (const child of node.children)
213
+ present.add(child.blockId);
214
+ }
215
+ };
216
+ collect(layout.top);
217
+ collect(layout.mid);
218
+ collect(layout.trailing);
219
+ const next = {
220
+ top: [...layout.top],
221
+ mid: [...layout.mid],
222
+ trailing: [...layout.trailing]
223
+ };
224
+ for (const def of WAIFU_PROMPT_BLOCKS) {
225
+ if (present.has(def.id))
226
+ continue;
227
+ next[def.defaultSection].push({ kind: "block", blockId: def.id, enabled: false });
228
+ }
229
+ return next;
230
+ }
231
+ //# sourceMappingURL=promptBlocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptBlocks.js","sourceRoot":"","sources":["../../src/orchestration/promptBlocks.ts"],"names":[],"mappings":"AA8BA,iGAAiG;AAEjG,MAAM,YAAY,GAAG;IACnB,gHAAgH;IAChH,mUAAmU;IACnU,mMAAmM;CACpM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;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AAE,KAAK,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -3,6 +3,7 @@ import { readdir } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { modelVisibleEmojiToken, stripLeakedContextHeader } from "../discord/normalization.js";
5
5
  import { splitWaifuReply, typingDelayMs } from "./messageSplit.js";
6
+ import { assembleWaifuPrompt, promptTagName, reconcileWaifuPromptLayout } from "./promptBlocks.js";
6
7
  import { extractReplyQuote } from "./replyQuote.js";
7
8
  import { getModel } from "../providers/catalog.js";
8
9
  import { createModelPipeline, ProviderPipelineError } from "../providers/pipelines.js";
@@ -1881,102 +1882,31 @@ export class RuntimeOrchestrator {
1881
1882
  .filter((emoji) => emoji.available)
1882
1883
  .map(modelVisibleEmojiToken)
1883
1884
  .join(" ");
1884
- const inputFormat = [
1885
- "Each incoming message in this conversation arrives in a chat-transcript shape so you can read Discord context:",
1886
- "An optional `> Author: preview` line appears first when the message is replying to an earlier one (Discord blockquote shape). The next line is `DisplayName: <body>` (the body may continue on additional lines). Optional `[attachments: Nx image]` and `[image_text: ...]` lines may follow, one per image with extracted text.",
1887
- "The `> Author: ...` quote, the `DisplayName:` prefix, and any bracketed lines are framing only. They are not part of what the speaker actually wrote, and they are not how Discord messages look."
1888
- ].join("\n");
1889
- const replyTargeting = [
1890
- "To reply to one specific earlier message, you may start your reply with a single `> Author: text-of-that-message` line. Copy the message text as closely as you can (small differences are fine; the runtime fuzzy-matches it). Put your actual reply on the next line.",
1891
- "The `>` quote line is not sent to Discord; it only tells the runtime which message your reply targets.",
1892
- "Use this instead of pinging when you want to address one specific earlier message. Otherwise omit the quote entirely and just write your reply.",
1893
- "Quote example - to reply specifically to Kevin's earlier `what's the weather like?` message, write:\n > Kevin: what's the weather like?\n sunny and warm\nThe runtime consumes the `> Kevin: ...` line to set Discord's reply target; only `sunny and warm` is sent."
1894
- ].join("\n");
1895
- const mentionPolicy = [
1896
- "To ping a user, write <@DisplayName> - where `DisplayName` is copied verbatim from the `DisplayName:` prefix on one of their messages. Example: a message that starts with `Kevin: hey` is pinged as <@Kevin>.",
1897
- "Do not ping a user who is already active in the recent chat or who just spoke. Mention their display name in plain text instead.",
1898
- "Only ping when you are reviving an older missed message, pulling back someone who has gone quiet, or a scene_direction explicitly asks for a ping."
1899
- ].join("\n");
1900
- const styleConstraints = [
1901
- "Write exactly one short phrase or one very short sentence, usually under 12 words.",
1902
- "Never write a second sentence.",
1903
- "This length rule overrides your persona, reply_style, and scene_direction. Even when asked for a longer or more thoughtful reply, compress it to one tiny conversational beat.",
1904
- "Avoid stacked clauses, multi-line replies, setup-plus-punchline chains, and explanations. A sharp fragment is usually stronger than a complete mini speech."
1905
- ].join("\n");
1906
- const hardRules = [
1907
- "Your reply is the raw message body that will be sent verbatim to Discord.",
1908
- "Your turn is exactly one Discord message body, never a transcript.",
1909
- "Do not write `Name: ...` or `DisplayName: ...` lines for any character, including yourself and every other waifu in the channel.",
1910
- "Do not draft another waifu's reply. If you find yourself doing that, stop and write only your own message.",
1911
- "Do not include bracketed metadata tags: no `[attachments: ...]`, no `[image_text: ...]`, no `[replying to: ...]`, no `[timestamp: ...]`, no `[reactions: ...]`, no `[index: ...]`, no `[scene_direction: ...]`, and no other `[tag: value]` constructions.",
1912
- "Do not begin with your own display name followed by a colon. Other than the optional leading `> Author: ...` reply-targeting line, begin with the first word you are actually saying.",
1913
- "Do not echo or paraphrase any prior message's bracketed framing tags.",
1914
- "Do not output physical actions, roleplay narration, or stage directions. No asterisks-wrapped actions like *smiles* or *waves*, no parenthetical stage notes like (hugs them), and no bracketed cues like [walks over].",
1915
- "The optional leading `> Author: ...` reply-targeting line is the only allowed prefix exception.",
1916
- "Never use raw Discord IDs for pings.",
1917
- "Use only listed server emojis."
1918
- ].join("\n");
1919
1885
  const personaText = waifu.persona.trim();
1920
1886
  const personalityContent = personaText
1921
1887
  ? `You are ${waifu.displayName}. Stay in character.\n${personaText}`
1922
1888
  : `You are ${waifu.displayName}. Stay in character.`;
1923
1889
  const scheduleContent = formatWaifuScheduleForPrompt(waifu);
1924
1890
  const waifuTag = promptTagName(waifu.name || waifu.id);
1925
- const environmentRules = [
1926
- "You are chatting in a live Discord text channel — this is a real chat room with real users, not a roleplay scene, story, or chat fiction.",
1927
- "Write one Discord-safe message per turn.",
1928
- "Reply with only what you would actually type into a chat box — no narration, no meta commentary, no describing yourself in the third person."
1929
- ].join("\n");
1930
- const promptSections = waifu.promptSections;
1931
- const behaviorSections = [
1932
- `<${waifuTag}_personality>\n${personalityContent}\n</${waifuTag}_personality>`,
1933
- `<${waifuTag}_shedule>\n${scheduleContent}\n</${waifuTag}_shedule>`,
1934
- promptSections.inputFormat ? `<context_message_structure>\n${inputFormat}\n</context_message_structure>` : null,
1935
- promptSections.environmentInstructions
1936
- ? `<environment_instructions>\n${environmentRules}\n</environment_instructions>`
1937
- : null,
1938
- promptSections.replyTargeting ? `<replying_to_message>\n${replyTargeting}\n</replying_to_message>` : null,
1939
- promptSections.mentionPolicy ? `<mention_policy>\n${mentionPolicy}\n</mention_policy>` : null,
1940
- promptSections.styleConstraints ? `<style_constraints>\n${styleConstraints}\n</style_constraints>` : null,
1941
- promptSections.hardRules ? `<hard_rules>\n${hardRules}\n</hard_rules>` : null
1942
- ].filter((section) => Boolean(section));
1943
- const toolUse = buildWaifuToolUseInstructions(waifu, availableWaifus, {
1891
+ const toolUseInstructions = buildWaifuToolUseInstructions(waifu, availableWaifus, {
1944
1892
  pickNextWaifu: pickNextWaifuToolActive,
1945
1893
  shortTermMemory: shortTermMemoryToolActive
1946
1894
  });
1947
- if (toolUse) {
1948
- behaviorSections.push(`<tool_use>\n${toolUse}\n</tool_use>`);
1949
- }
1950
- const identityBlock = `<${waifuTag}_identity>\nYou are acting as ${waifu.displayName || waifu.name || waifu.id} in a discord server together with real people and other waifus\n</${waifuTag}_identity>`;
1951
- const behaviorBlock = `<${waifuTag}_behavior>\n${behaviorSections.join("\n")}\n</${waifuTag}_behavior>`;
1952
- const allMemoryLines = [...longTermLines, ...shortTermLines];
1953
- const relevantMemoriesBlock = allMemoryLines.length
1954
- ? `<${waifuTag}_relevant_memories>\n${allMemoryLines.join("\n")}\n</${waifuTag}_relevant_memories>`
1955
- : undefined;
1956
- const directorNotesBlock = promptSections.directorNotes ? buildDirectorNotesBlock() : undefined;
1957
- const activeParticipantsBlock = `<active_chat_participants>\n${activeChatParticipants.length
1958
- ? activeChatParticipants.map((participant) => `- ${participant.displayName}`).join("\n")
1959
- : "(none)"}\n</active_chat_participants>`;
1960
- const availableEmojisBlock = `<server_emojis>\n${emojiList || "(none cached)"}\n</server_emojis>`;
1961
- const midSystemBlock = [directorNotesBlock, activeParticipantsBlock, availableEmojisBlock]
1962
- .filter((section) => Boolean(section))
1963
- .join("\n");
1964
- const personalityBlock = promptSections.personality
1965
- ? `<${waifuTag}_personality>\n${personalityContent}\n</${waifuTag}_personality>`
1966
- : undefined;
1967
- const currentlyDoing = currentlyDoingForWaifu(waifu, new Date());
1968
- const currentlyDoingBlock = currentlyDoing
1969
- ? `<currently_doing>${currentlyDoing}</currently_doing>`
1970
- : undefined;
1971
- const sceneDirectionText = options?.sceneDirection?.trim();
1972
- const sceneDirectionBlock = sceneDirectionText
1973
- ? `<scene_direction>${sceneDirectionText}</scene_direction>`
1974
- : undefined;
1975
- const trailingSystemBlock = [relevantMemoriesBlock, personalityBlock, currentlyDoingBlock, sceneDirectionBlock]
1976
- .filter((section) => Boolean(section))
1977
- .join("\n");
1978
- const systemPrompt = [identityBlock, behaviorBlock].join("\n");
1979
- return { systemPrompt, midSystemBlock, trailingSystemBlock };
1895
+ const blockContext = {
1896
+ waifuTag,
1897
+ displayName: waifu.displayName || waifu.name || waifu.id,
1898
+ personalityContent,
1899
+ scheduleContent,
1900
+ toolUseInstructions,
1901
+ activeParticipantDisplayNames: activeChatParticipants.map((participant) => participant.displayName),
1902
+ emojiList,
1903
+ memoryLines: [...longTermLines, ...shortTermLines],
1904
+ currentlyDoing: currentlyDoingForWaifu(waifu, new Date()),
1905
+ sceneDirection: options?.sceneDirection?.trim() || undefined
1906
+ };
1907
+ // The slot→string mapping is fixed; the composition of each slot is driven by the waifu's
1908
+ // editable prompt layout (see src/orchestration/promptBlocks.ts).
1909
+ return assembleWaifuPrompt(reconcileWaifuPromptLayout(waifu.promptLayout), blockContext);
1980
1910
  }
1981
1911
  buildOrchestratorSystemPrompt(orchestrator, server, availableWaifus, replyRequired = false) {
1982
1912
  if (orchestrator.useLegacyPrompt) {
@@ -2551,15 +2481,6 @@ function formatWaifuAvailabilityForOrchestratorPrompt(waifu, now) {
2551
2481
  function localTimeOfDayMinutes(date) {
2552
2482
  return date.getHours() * 60 + date.getMinutes();
2553
2483
  }
2554
- function buildDirectorNotesBlock() {
2555
- const notes = [
2556
- "Keep your reply short.",
2557
- "Do not repeat what the previous waifu just said.",
2558
- "Do not repeat a person's name when recent context already makes the target clear.",
2559
- "To pull a quiet person back in, use their <@Name> tag instead of repeating their name; do not tag them again if anyone already tagged them recently."
2560
- ];
2561
- return `<director_notes>\n${notes.join("\n")}\n</director_notes>`;
2562
- }
2563
2484
  export function currentlyDoingForWaifu(waifu, now) {
2564
2485
  const currentMinutes = localTimeOfDayMinutes(now);
2565
2486
  for (const interval of waifu.availability.busy) {
@@ -2891,14 +2812,6 @@ function decrementActive(map, key) {
2891
2812
  map.delete(key);
2892
2813
  }
2893
2814
  }
2894
- function promptTagName(value) {
2895
- const normalized = value
2896
- .trim()
2897
- .toLowerCase()
2898
- .replace(/[^a-z0-9_-]+/g, "_")
2899
- .replace(/^_+|_+$/g, "");
2900
- return /^[a-z]/.test(normalized) ? normalized : `waifu_${normalized || "unknown"}`;
2901
- }
2902
2815
  function defaultSleep(ms, signal) {
2903
2816
  return new Promise((resolve, reject) => {
2904
2817
  if (signal?.aborted) {