( extraGuidelines?: string[], skipIndex = false, )
| 20 | * per-type <scope> guidance embedded in XML-style <type> blocks. |
| 21 | */ |
| 22 | export function buildCombinedMemoryPrompt( |
| 23 | extraGuidelines?: string[], |
| 24 | skipIndex = false, |
| 25 | ): string { |
| 26 | const autoDir = getAutoMemPath() |
| 27 | const teamDir = getTeamMemPath() |
| 28 | |
| 29 | const howToSave = skipIndex |
| 30 | ? [ |
| 31 | '## How to save memories', |
| 32 | '', |
| 33 | "Write each memory to its own file in the chosen directory (private or team, per the type's scope guidance) using this frontmatter format:", |
| 34 | '', |
| 35 | ...MEMORY_FRONTMATTER_EXAMPLE, |
| 36 | '', |
| 37 | '- Keep the name, description, and type fields in memory files up-to-date with the content', |
| 38 | '- Organize memory semantically by topic, not chronologically', |
| 39 | '- Update or remove memories that turn out to be wrong or outdated', |
| 40 | '- Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one.', |
| 41 | ] |
| 42 | : [ |
| 43 | '## How to save memories', |
| 44 | '', |
| 45 | 'Saving a memory is a two-step process:', |
| 46 | '', |
| 47 | "**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:", |
| 48 | '', |
| 49 | ...MEMORY_FRONTMATTER_EXAMPLE, |
| 50 | '', |
| 51 | `**Step 2** — add a pointer to that file in the same directory's \`${ENTRYPOINT_NAME}\`. Each directory (private and team) has its own \`${ENTRYPOINT_NAME}\` 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 \`${ENTRYPOINT_NAME}\`.`, |
| 52 | '', |
| 53 | `- Both \`${ENTRYPOINT_NAME}\` indexes are loaded into your conversation context — lines after ${MAX_ENTRYPOINT_LINES} will be truncated, so keep them concise`, |
| 54 | '- Keep the name, description, and type fields in memory files up-to-date with the content', |
| 55 | '- Organize memory semantically by topic, not chronologically', |
| 56 | '- Update or remove memories that turn out to be wrong or outdated', |
| 57 | '- Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one.', |
| 58 | ] |
| 59 | |
| 60 | const lines = [ |
| 61 | '# Memory', |
| 62 | '', |
| 63 | `You have a persistent, file-based memory system with two directories: a private directory at \`${autoDir}\` and a shared team directory at \`${teamDir}\`. ${DIRS_EXIST_GUIDANCE}`, |
| 64 | '', |
| 65 | "You should build up this memory system over time so that future conversations can have a complete picture of who the user is, how they'd like to collaborate with you, what behaviors to avoid or repeat, and the context behind the work the user gives you.", |
| 66 | '', |
| 67 | '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.', |
| 68 | '', |
| 69 | '## Memory scope', |
| 70 | '', |
| 71 | 'There are two scope levels:', |
| 72 | '', |
| 73 | `- private: memories that are private between you and the current user. They persist across conversations with only this specific user and are stored at the root \`${autoDir}\`.`, |
| 74 | `- team: memories that are shared with and contributed by all of the users who work within this project directory. Team memories are synced at the beginning of every session and they are stored at \`${teamDir}\`.`, |
| 75 | '', |
| 76 | ...TYPES_SECTION_COMBINED, |
| 77 | ...WHAT_NOT_TO_SAVE_SECTION, |
| 78 | '- You MUST avoid saving sensitive data within shared team memories. For example, never save API keys or user credentials.', |
| 79 | '', |
nothing calls this directly
no test coverage detected