···11+You summarize a single agent session into a markdown-based memory draft.
22+Use session_context for who/when details.
33+Return ONLY a JSON object with keys:
44+summary (string),
55+session_summary (array of {title, value}),
66+temporary_facts (array of {title, value}),
77+tasks (array of {text, done}),
88+follow_ups (array of {text, done}),
99+promote (object with goals_projects and key_facts arrays of {title, value}).
1010+If nothing applies, use empty arrays and empty strings.
1111+Promote only stable, high-signal items.
···11+{
22+ "session_context": {{toJSON .SessionContext}},
33+ "conversation": {{toJSON .Conversation}},
44+ "existing_tasks": {{toJSON .ExistingTasks}},
55+ "existing_follow_ups": {{toJSON .ExistingFollowUps}},
66+ "rules": [
77+ "Short-term memory is public. Do NOT include private or sensitive info in summary/session_summary/temporary_facts/tasks/follow_ups.",
88+ "Use the same language as the user for titles and values; keep Session Summary keys labeled as Users/Datetime/Event/Result.",
99+ "Session summary items must be single-topic. Set title to the topic name.",
1010+ "Session summary value must be newline-separated key-value lines: Users: ..., Datetime: ..., Event: ..., Result: ... (omit unknowns).",
1111+ "If session_context includes counterparty info, use it instead of generic labels like \"user\".",
1212+ "Temporary facts title is the fact group name; value is newline-separated key-value lines (e.g., 网站 URL: ..., API 示例: ...).",
1313+ "Temporary facts should preserve key metadata such as URLs, terms, identifiers, IDs, or ticket numbers when they matter to future work.",
1414+ "Keep items concise but specific.",
1515+ "If an existing task or follow-up was completed in this session, include it with done=true.",
1616+ "Prefer to reuse the wording from existing_tasks when updating status.",
1717+ "If session_context.counterparty_label is present, use that exact label in tasks/follow_ups instead of generic words like user/用户/对方.",
1818+ "Long-term promotion must be extremely strict: only include ONE precious, long-lived item at most, and only if the user explicitly asked to remember it.",
1919+ "Do NOT promote short-term tasks, one-off details, or time-bound items.",
2020+ "If unsure, leave the field empty."
2121+ ]
2222+}
···11+You merge short-term memory entries for the same day.
22+Return ONLY a JSON object with keys: summary, session_summary, temporary_facts, tasks, follow_ups.
33+Each list item must keep the same shape as input.
44+Summary must reflect the merged content and be one short sentence.
···11+{
22+ "existing": {{toJSON .Existing}},
33+ "incoming": {{toJSON .Incoming}},
44+ "rules": [
55+ "These are same-day short-term items. Merge semantically and deduplicate.",
66+ "Short-term memory is public. Do NOT include private or sensitive info.",
77+ "Session summary title is the topic name; value is newline-separated key-value lines (Users/Datetime/Event/Result).",
88+ "Temporary facts title is the fact group name; value is newline-separated key-value lines.",
99+ "Merge items with overlapping meaning even if titles differ. You may rename titles to unify duplicates.",
1010+ "Prefer a single canonical title when multiple entries describe the same topic.",
1111+ "Preserve all concrete details when merging; do not lose facts from incoming or existing items.",
1212+ "Merge overlapping link lists into one list (dedupe URLs).",
1313+ "Within a Session Summary value, each key (Users/Datetime/Event/Result) must appear at most once.",
1414+ "Within a Temporary Facts value, do not repeat the same key or URL.",
1515+ "Prefer the most recent information when conflicts occur.",
1616+ "Preserve important metadata in temporary_facts such as URLs, terms, identifiers, IDs, or ticket numbers.",
1717+ "Keep items concise.",
1818+ "Tasks/Follow-ups: merge duplicates even if wording differs; keep one canonical item.",
1919+ "If any duplicate is done=true, the merged item must be done=true.",
2020+ "If unsure, keep the existing item and add the new one only if distinct."
2121+ ]
2222+}
···11+{
22+ "tasks": {{toJSON .Tasks}},
33+ "rules": [
44+ "Merge duplicate tasks even if wording differs.",
55+ "Keep one canonical task per meaning.",
66+ "If any duplicate is done=true, the merged task must be done=true.",
77+ "Do not invent new tasks."
88+ ]
99+}
···11+{
22+ "existing": {{toJSON .Existing}},
33+ "updates": {{toJSON .Updates}},
44+ "rules": [
55+ "Match updates to existing tasks if they refer to the same task even with different wording.",
66+ "Return match_index = -1 if no existing task matches.",
77+ "Each update should map to at most one existing task."
88+ ]
99+}
+37-5
docs/prompt.md
···87878888These are prompts sent through separate `llm.Request` calls outside the main tool-using turn loop.
89899090+## Template Index (Per File)
9191+9292+| Template | Role | Purpose |
9393+|---|---|---|
9494+| `agent/prompts/system.tmpl` | system | Renders the main system prompt (Identity, Blocks, Tools, response format, Rules). |
9595+| `agent/prompts/intent_system.tmpl` | system | Constrains intent inference output schema (JSON contract). |
9696+| `agent/prompts/intent_user.tmpl` | user | Carries `task/history` plus built-in intent inference rules. |
9797+| `telegramcmd/prompts/memory_draft_system.tmpl` | system | Defines the output contract for single-session memory draft generation. |
9898+| `telegramcmd/prompts/memory_draft_user.tmpl` | user | Carries session context, dialogue snippets, existing tasks/follow-ups, and summarization rules. |
9999+| `telegramcmd/prompts/memory_merge_system.tmpl` | system | Defines the output contract for same-day short-term memory merge. |
100100+| `telegramcmd/prompts/memory_merge_user.tmpl` | user | Carries existing/incoming memory content and merge rules. |
101101+| `telegramcmd/prompts/memory_task_match_system.tmpl` | system | Defines the output contract for task mapping (`update_index/match_index`). |
102102+| `telegramcmd/prompts/memory_task_match_user.tmpl` | user | Carries existing tasks, updates, and matching rules. |
103103+| `telegramcmd/prompts/memory_task_dedup_system.tmpl` | system | Defines the output contract for semantic task deduplication. |
104104+| `telegramcmd/prompts/memory_task_dedup_user.tmpl` | user | Carries tasks and deduplication rules. |
105105+90106### 1) Intent inference
9110792108- File/Function: `agent/intent.go` / `InferIntent(...)`
···95111 - `agent/prompts/intent_user.tmpl`
96112 - Renderer: `agent/intent_template.go` (via `internal/prompttmpl`)
97113- Purpose: infer structured user intent and ambiguity level
9898-- Primary input: current `task`, trimmed recent `history`(规则由模板内置)
114114+- Primary input: current `task`, trimmed recent `history` (rules are embedded in the template)
99115- Output: `Intent{goal, deliverable, constraints, ambiguities, ask}`
100116- JSON required: **Yes** (`ForceJSON=true`)
101117···182198### 12) Telegram memory draft generation
183199184200- File/Function: `cmd/mistermorph/telegramcmd/command.go` / `BuildMemoryDraft(...)`
201201+- Templates:
202202+ - `cmd/mistermorph/telegramcmd/prompts/memory_draft_system.tmpl`
203203+ - `cmd/mistermorph/telegramcmd/prompts/memory_draft_user.tmpl`
204204+ - Renderer: `cmd/mistermorph/telegramcmd/memory_prompts.go`
185205- Purpose: convert one session into structured short-term memory draft
186186-- Primary input: session context, conversation, existing tasks/follow-ups, memory rules
206206+- Primary input: session context, conversation, existing tasks/follow-ups
187207- Output: `memory.SessionDraft`
188208- JSON required: **Yes** (`ForceJSON=true`)
189209190210### 13) Telegram semantic merge for short-term memory
191211192212- File/Function: `cmd/mistermorph/telegramcmd/command.go` / `SemanticMergeShortTerm(...)`
213213+- Templates:
214214+ - `cmd/mistermorph/telegramcmd/prompts/memory_merge_system.tmpl`
215215+ - `cmd/mistermorph/telegramcmd/prompts/memory_merge_user.tmpl`
216216+ - Renderer: `cmd/mistermorph/telegramcmd/memory_prompts.go`
193217- Purpose: semantically merge same-day short-term memory
194194-- Primary input: existing content + incoming draft + merge rules
218218+- Primary input: existing content + incoming draft
195219- Output: merged `memory.ShortTermContent` + summary string
196220- JSON required: **Yes** (`ForceJSON=true`)
197221198222### 14) Telegram semantic task matching
199223200224- File/Function: `cmd/mistermorph/telegramcmd/command.go` / `semanticMatchTasks(...)`
225225+- Templates:
226226+ - `cmd/mistermorph/telegramcmd/prompts/memory_task_match_system.tmpl`
227227+ - `cmd/mistermorph/telegramcmd/prompts/memory_task_match_user.tmpl`
228228+ - Renderer: `cmd/mistermorph/telegramcmd/memory_prompts.go`
201229- Purpose: map incoming task updates onto existing tasks
202202-- Primary input: existing task list + update task list + matching rules
230230+- Primary input: existing task list + update task list
203231- Output: `[]taskMatch{update_index, match_index}`
204232- JSON required: **Yes** (`ForceJSON=true`)
205233206234### 15) Telegram semantic task deduplication
207235208236- File/Function: `cmd/mistermorph/telegramcmd/command.go` / `semanticDedupTaskItems(...)`
237237+- Templates:
238238+ - `cmd/mistermorph/telegramcmd/prompts/memory_task_dedup_system.tmpl`
239239+ - `cmd/mistermorph/telegramcmd/prompts/memory_task_dedup_user.tmpl`
240240+ - Renderer: `cmd/mistermorph/telegramcmd/memory_prompts.go`
209241- Purpose: deduplicate semantically equivalent task items
210210-- Primary input: task list + dedup rules
242242+- Primary input: task list
211243- Output: deduplicated `[]memory.TaskItem`
212244- JSON required: **Yes** (`ForceJSON=true`)
213245