( newMessageCount: number, existingMemories: string, skipIndex = false, )
| 99 | * is baked into each type block, no separate routing section needed). |
| 100 | */ |
| 101 | export function buildExtractCombinedPrompt( |
| 102 | newMessageCount: number, |
| 103 | existingMemories: string, |
| 104 | skipIndex = false, |
| 105 | ): string { |
| 106 | if (!feature('TEAMMEM')) { |
| 107 | return buildExtractAutoOnlyPrompt( |
| 108 | newMessageCount, |
| 109 | existingMemories, |
| 110 | skipIndex, |
| 111 | ) |
| 112 | } |
| 113 | |
| 114 | const howToSave = skipIndex |
| 115 | ? [ |
| 116 | '## How to save memories', |
| 117 | '', |
| 118 | "Write each memory to its own file in the chosen directory (private or team, per the type's scope guidance) using this frontmatter format:", |
| 119 | '', |
| 120 | ...MEMORY_FRONTMATTER_EXAMPLE, |
| 121 | '', |
| 122 | '- Organize memory semantically by topic, not chronologically', |
| 123 | '- Update or remove memories that turn out to be wrong or outdated', |
| 124 | '- Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one.', |
| 125 | ] |
| 126 | : [ |
| 127 | '## How to save memories', |
| 128 | '', |
| 129 | 'Saving a memory is a two-step process:', |
| 130 | '', |
| 131 | "**Step 1** — write the memory to its own file in the chosen directory (private or team, per the type's scope guidance) using this frontmatter format:", |
| 132 | '', |
| 133 | ...MEMORY_FRONTMATTER_EXAMPLE, |
| 134 | '', |
| 135 | "**Step 2** — add a pointer to that file in the same directory's `MEMORY.md`. Each directory (private and team) has its own `MEMORY.md` index — each entry should be one line, under ~150 characters: `- [Title](file.md) — one-line hook`. They have no frontmatter. Never write memory content directly into a `MEMORY.md`.", |
| 136 | '', |
| 137 | '- Both `MEMORY.md` indexes are loaded into your system prompt — lines after 200 will be truncated, so keep them concise', |
| 138 | '- Organize memory semantically by topic, not chronologically', |
| 139 | '- Update or remove memories that turn out to be wrong or outdated', |
| 140 | '- Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one.', |
| 141 | ] |
| 142 | |
| 143 | return [ |
| 144 | opener(newMessageCount, existingMemories), |
| 145 | '', |
| 146 | 'If the user explicitly asks you to remember something, save it immediately as whichever type fits best. If they ask you to forget something, find and remove the relevant entry.', |
| 147 | '', |
| 148 | ...TYPES_SECTION_COMBINED, |
| 149 | ...WHAT_NOT_TO_SAVE_SECTION, |
| 150 | '- You MUST avoid saving sensitive data within shared team memories. For example, never save API keys or user credentials.', |
| 151 | '', |
| 152 | ...howToSave, |
| 153 | ].join('\n') |
| 154 | } |
| 155 |
no test coverage detected