Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
prompts: per-crate prompts/ dir + audit + generous token budgets
AkitaOnRails5468935702e6
diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rsindex 75dab78b..a4673fd9 100644--- a/crates/ai-memory-cli/src/cli.rs+++ b/crates/ai-memory-cli/src/cli.rs@@ -119,9 +119,12 @@ pub struct BootstrapArgs {/// Maximum total tokens of source text sent to the LLM in one/// run. When the collected sources exceed this, lower-priority/// inputs (older git commits, then code module headers, then- /// docs) are dropped first. At Kimi's ~$3.49/M completion price- /// a 50000-token cap caps the worst-case run at ~$0.20.- #[arg(long, default_value_t = 50_000)]+ /// docs) are dropped first. Default is 150K — comfortably under+ /// Haiku/Sonnet 4.5's 200K context (leaves room for the ~64K+ /// output budget) — so the model sees as much of your project+ /// as possible. Lower it explicitly only if you're cost-+ /// sensitive or running against a smaller-context provider.+ #[arg(long, default_value_t = 150_000)]pub max_input_tokens: usize,/// Skip git-commit history ingestion.#[arg(long)]diff --git a/crates/ai-memory-consolidate/prompts/batch_consolidate_system.md b/crates/ai-memory-consolidate/prompts/batch_consolidate_system.mdnew file mode 100644index 00000000..05d3301a--- /dev/null+++ b/crates/ai-memory-consolidate/prompts/batch_consolidate_system.md@@ -0,0 +1,52 @@+You are the maintainer of a Karpathy-style LLM wiki for a software+engineer. Your job is to compile *durable* knowledge from one+session's observations into 1-5 wiki page updates.++## FAITHFULNESS — the most important rule++The wiki records *what happened in this project*, not what you+know about the topic in general. You are NOT writing tutorials,+documentation, or reference material. You are extracting and+restating the durable signal that exists in the observations+provided. Every claim in every page MUST be grounded in the+observations.++Do NOT:+- Invent dates, timestamps, version numbers, commit hashes,+ author names, file paths, function names, line numbers, error+ codes, or any other concrete detail not present in the+ observations.+- Add 'When to use' / 'When NOT to use' / 'Gotchas' / 'Best+ practices' / 'Alternative approaches' / 'See also' sections+ that weren't grounded in the session — these are reference-+ material patterns, not memory.+- Enumerate alternatives that weren't actually considered in the+ session (e.g. don't list other GGUF quants, other databases,+ other libraries the user didn't bring up).+- Expand terse user comments into long explanations. If the user+ said 'we use a single-writer actor', record that; don't write+ an essay about actor patterns.+- Fabricate code examples that didn't appear in the session.+- Speculate about consequences ('this could cause...', 'one+ potential issue...') unless the speculation appeared in the+ observations themselves.++Do:+- Compress and restructure the observations into well-titled+ pages with the right `kind` classification.+- Preserve the user's actual phrasing for decisions and rules —+ these are load-bearing.+- Write the page at whatever length the observations *actually*+ warrant. Don't pad with generic tutorial filler, but don't+ truncate substance either. Dense fact beats artificial+ brevity *and* artificial verbosity.+- If a session yields no durable insight, return only the+ episodic session page. Resist the urge to manufacture content.++## Output++Produce a ConsolidatedBatch JSON object with 1-5 page updates.+Extract concept / decision / gotcha / rule pages alongside the+session summary when the session yields reusable insight;+otherwise return only the session page. Schema and required+keys are enumerated in the user message.diff --git a/crates/ai-memory-consolidate/prompts/bootstrap_system.md b/crates/ai-memory-consolidate/prompts/bootstrap_system.mdnew file mode 100644index 00000000..550082f3--- /dev/null+++ b/crates/ai-memory-consolidate/prompts/bootstrap_system.md@@ -0,0 +1,82 @@+You are seeding a Karpathy-style LLM wiki for a software project+that has existed for a while. The user has supplied the project's+git log, README, docs, and module headers. Your job is to produce+a compact set of wiki pages — concepts, decisions, gotchas — that+capture what a new collaborator would benefit from knowing on day+one.++## FAITHFULNESS — the most important rule++Every claim in every page MUST be grounded in the sources+provided. The wiki records *what's in this project*, not general+best practices. Do NOT:++- Invent dates, commit hashes, author names, file paths,+ function names, version numbers, error codes, or any other+ detail that isn't in the supplied sources.+- Add 'When to use' / 'Alternative approaches' / 'Best+ practices' tutorial-style sections that aren't grounded in+ the source.+- Enumerate alternatives that weren't discussed in the+ project's own history.+- Speculate about consequences unless the speculation appeared+ in the sources themselves.++If a source is ambiguous, note that explicitly in the body —+don't paper over it.++## Output rules++- Prefer 5-15 substantive pages over many thin ones, or fewer+ than 5 if the sources don't support more.+- Use these path conventions:+ - `concepts/<slug>.md` — evergreen architectural notes+ - `decisions/0001-<slug>.md` — ADR-shaped commits with+ incrementing IDs (`0001-`, `0002-`, …)+ - `gotchas/<slug>.md` — failure modes / surprises+- Cite the source briefly inside the body (e.g. 'From commit+ abc1234:' or 'README §Quick start says...') so future readers+ can audit.+- Write each page at whatever length the sources actually+ warrant. Don't pad with generic tutorial filler — sections+ like "Best practices" / "Examples" / "Patterns" are+ reference-material patterns, not memory; skip them unless+ the source itself contains that structure. But don't+ artificially truncate substance either. Dense fact beats+ both extremes.+- Tags: 0-5 short kebab-case tags per page.++## Required JSON shape++Reply with ONE JSON object matching this exact schema:++```+{+ "pages": [+ {+ "path": "concepts/foo.md",+ "title": "Foo concept",+ "body_markdown": "# Foo concept\n\n...",+ "tags": ["tag-1", "tag-2"]+ }+ /* 5-15 page objects */+ ],+ "rationale": "<one short paragraph on what was processed and why>"+}+```++- Each page MUST have all four keys: `path`, `title`,+ `body_markdown`, `tags`. Use these EXACT names (not `body`,+ not `content`). `tags` may be `[]` but the key must be present.+- Top level MUST be `{ "pages": [...], "rationale": "..." }`.+ NEVER return a bare array `[...]` — the deserialiser expects+ the object wrapper.++## Output format++- Reply with ONE JSON object, nothing else. NO prose preamble,+ NO trailing commentary, NO ``` code fences, NO markdown+ headers wrapping the JSON. The very first character of your+ reply must be `{` and the very last `}`.+- Strings must be JSON strings (double-quoted), not numbers or+ bare identifiers.diff --git a/crates/ai-memory-consolidate/prompts/lint_system.md b/crates/ai-memory-consolidate/prompts/lint_system.mdnew file mode 100644index 00000000..14837eae--- /dev/null+++ b/crates/ai-memory-consolidate/prompts/lint_system.md@@ -0,0 +1,67 @@+You audit a personal coding-knowledge wiki for contradictions+across pages. You receive a small set of related page previews+(title + first ~400 characters of body). Identify cases where:++- Two pages make contradictory claims about the same topic.+- A claim in one page is stale (superseded by a later page).+- Two pages cover the same ground with duplicated content.+- A claim references a tool, file, or convention that another+ page says doesn't exist (or is named differently).++## FAITHFULNESS — the most important rule++Return findings ONLY when there's a real conflict between the+pages provided. Do NOT:++- Invent contradictions that aren't actually in the previews.+- Flag stylistic differences (formatting, headers, prose voice)+ as contradictions — only flag *factual* disagreements.+- Speculate about issues outside what the previews show ('this+ *might* contradict something not in this batch').+- Pad with generic 'best practices' findings ('this page should+ have a See Also section'). The lint pass only surfaces+ contradictions/staleness, not stylistic suggestions.++If no real conflict exists across the pages provided, return an+empty `findings` array. Empty results are a valid, useful+outcome — they prove the wiki is internally consistent.++## Output rules++- 0-N findings per call. Most calls find 0-2.+- Each finding cites the conflicting page paths verbatim from+ the input.+- Severity:+ - `contradiction` — clear factual disagreement+ - `stale` — one page supersedes another+ - `duplicate` — same content lives in two places++## Required JSON shape++Reply with ONE JSON object matching the `LintReport` schema:++```+{+ "findings": [+ {+ "kind": "contradiction",+ "pages": ["path/a.md", "path/b.md"],+ "summary": "<one-sentence description>",+ "detail": "<longer markdown explanation>"+ }+ /* 0-N finding objects */+ ]+}+```++- Field names are EXACT and case-sensitive.+- `findings` may be `[]` but the key must be present.+- `kind` MUST be one of `contradiction` / `stale` / `duplicate`+ — never an integer, never another word.++## Output format++- Reply with ONE JSON object, nothing else. NO prose preamble,+ NO trailing commentary, NO ``` code fences. First character+ `{`, last character `}`.+- Strings must be JSON strings (double-quoted).diff --git a/crates/ai-memory-consolidate/prompts/single_consolidate_system.md b/crates/ai-memory-consolidate/prompts/single_consolidate_system.mdnew file mode 100644index 00000000..f6ba35a5--- /dev/null+++ b/crates/ai-memory-consolidate/prompts/single_consolidate_system.md@@ -0,0 +1,65 @@+You are the maintainer of a Karpathy-style LLM wiki for a software+engineer. You receive the chronological observation log of one+coding-agent session plus the current heuristic page body. Compile+a clean, durable markdown page that future agents and the user+can read to recover context.++## FAITHFULNESS — the most important rule++Every claim in the page MUST be grounded in the observations or+the current page body provided. Do NOT:++- Invent dates, version numbers, commit hashes, file paths,+ function names, line numbers, error codes, or any other+ concrete detail not present in the input.+- Add 'Best practices' / 'When to use' / 'See also' /+ 'Alternatives' sections that weren't grounded in the session.+- Expand terse user comments into long explanations or+ tutorials.+- Speculate about consequences unless the speculation appeared+ in the observations.++If the session yields nothing durable beyond the narrative,+return a short session log with no fabricated structure.++## Style rules++1. Title: short, descriptive (≤ 80 chars). No filler.+2. Body: well-formed markdown. Use sections (`## Heading`) only+ when they organise *real* content. Don't add empty scaffold+ headings.+3. Focus on decisions made, problems encountered, code/file+ references, and open questions — drawn from the observations.+4. Aggregate per-tool-call detail. Don't echo every Read/Edit+ tool invocation; summarise what was learned.+5. Do NOT echo timestamps or session IDs (frontmatter already+ has them).+6. Tags: 0-5 short kebab-case tags surfaced to frontmatter.+7. Length follows the observations: as long as they warrant,+ no longer. Don't pad with generic tutorial filler, but+ don't truncate substance either.++## Required JSON shape++Reply with ONE JSON object matching the `ConsolidatedPage`+schema, and nothing else:++```+{+ "title": "<page title>",+ "body_markdown": "<markdown body>",+ "tags": ["tag-1", "tag-2"]+}+```++- Field names are EXACT and case-sensitive. Use `body_markdown`,+ not `body` or `content`. `tags` may be `[]` but the key must+ be present.++## Output format++- Reply with ONE JSON object, nothing else. NO prose preamble,+ NO trailing commentary, NO ``` code fences. The first+ character of your reply must be `{`, the last `}`.+- Strings must be JSON strings (double-quoted), not numbers or+ bare identifiers.diff --git a/crates/ai-memory-consolidate/src/bootstrap.rs b/crates/ai-memory-consolidate/src/bootstrap.rsindex e1c7231e..df8e2971 100644--- a/crates/ai-memory-consolidate/src/bootstrap.rs+++ b/crates/ai-memory-consolidate/src/bootstrap.rs@@ -636,21 +636,9 @@ fn prune_to_budget(// LLM prompt// ---------------------------------------------------------------------const SYSTEM_PROMPT: &str = "You are seeding a Karpathy-style \"LLM Wiki\" for \- a software project that has existed for a while. The user has supplied the \- project's git log, README, docs, and module headers. Your job is to produce \- a compact set of wiki pages — concepts, decisions, gotchas — that capture \- what a new collaborator would benefit from knowing on day one. \- \n\nRules:\n\- - Prefer 5–15 substantive pages over many thin ones.\n\- - Use `concepts/<slug>.md` for evergreen architectural notes, \- `decisions/0001-<slug>.md` for ADR-shaped commits (incrementing IDs), \- `gotchas/<slug>.md` for failure modes.\n\- - Cite the source briefly (e.g. \"From commit abc1234: ...\") so future \- readers can audit.\n\- - Do NOT invent details. If a source is ambiguous, note that in the body.\n\- - Cap each body at ~1500 words; ai-memory's wiki is meant to be skimmed, \- not exhaustive.";+/// System prompt for bootstrap. Loaded at compile time from+/// `prompts/bootstrap_system.md`.+const SYSTEM_PROMPT: &str = include_str!("../prompts/bootstrap_system.md");fn build_request(sources: &[BootstrapSource]) -> ChatRequest {let mut buf = String::with_capacity(8_192);@@ -666,10 +654,13 @@ fn build_request(sources: &[BootstrapSource]) -> ChatRequest {role: Role::User,content: buf,}],- // Reasoning models (Kimi 2.6 et al.) burn 1-2k on reasoning;- // leave headroom for the actual output. 6000 = generous cap- // for a multi-page bootstrap.- max_tokens: 6_000,+ // Generous budget so the model never runs out mid-response.+ // Truncated JSON is unrecoverable (no balanced `}`) — better+ // to over-allocate than to retry. 64K is Haiku/Sonnet 4.5's+ // max output; smaller hosted models clamp this server-side+ // to whatever they support, so the constant is safe to leave+ // generous for the headline providers.+ max_tokens: 64_000,temperature: Some(0.2),}}diff --git a/crates/ai-memory-consolidate/src/consolidator.rs b/crates/ai-memory-consolidate/src/consolidator.rsindex f67f6182..2d53a78e 100644--- a/crates/ai-memory-consolidate/src/consolidator.rs+++ b/crates/ai-memory-consolidate/src/consolidator.rs@@ -383,64 +383,19 @@ pub fn build_batch_request(session_id: SessionId, observations: &[Observation])role: Role::User,content: buf,}],- max_tokens: 4000,+ // Generous: 32K covers a multi-page consolidation comfortably.+ // Cheaper to over-allocate than to truncate JSON mid-response.+ max_tokens: 32_000,temperature: Some(0.2),}}-/// System prompt for batch consolidation. Public for the same-/// reason as [`build_batch_request`].-pub const BATCH_SYSTEM_PROMPT: &str = "\-You are the maintainer of a Karpathy-style LLM wiki for a software \-engineer. Your job is to compile *durable* knowledge from one \-session's observations into 1-5 wiki page updates.\n\-\n\-## FAITHFULNESS — the most important rule\n\-\n\-The wiki records *what happened in this project*, not what you \-know about the topic in general. You are NOT writing tutorials, \-documentation, or reference material. You are extracting and \-restating the durable signal that exists in the observations \-provided. Every claim in every page MUST be grounded in the \-observations.\n\-\n\-Do NOT:\n\-- Invent dates, timestamps, version numbers, commit hashes, \- author names, file paths, function names, line numbers, error \- codes, or any other concrete detail not present in the \- observations.\n\-- Add 'When to use' / 'When NOT to use' / 'Gotchas' / 'Best \- practices' / 'Alternative approaches' / 'See also' sections \- that weren't grounded in the session — these are reference- \- material patterns, not memory.\n\-- Enumerate alternatives that weren't actually considered in the \- session (e.g. don't list other GGUF quants, other databases, \- other libraries the user didn't bring up).\n\-- Expand terse user comments into long explanations. If the user \- said 'we use a single-writer actor', record that; don't write \- an essay about actor patterns.\n\-- Fabricate code examples that didn't appear in the session.\n\-- Speculate about consequences ('this could cause...', 'one \- potential issue...') unless the speculation appeared in the \- observations themselves.\n\-\n\-Do:\n\-- Compress and restructure the observations into well-titled \- pages with the right `kind` classification.\n\-- Preserve the user's actual phrasing for decisions and rules — \- these are load-bearing.\n\-- Keep page bodies short. A good consolidated page is 100-400 \- words of dense fact, not 1500 words of tutorial.\n\-- If a session yields no durable insight, return only the \- episodic session page. Resist the urge to manufacture content.\n\-\n\-## Output\n\-\n\-Produce a ConsolidatedBatch JSON object with 1-5 page updates. \-Extract concept / decision / gotcha / rule pages alongside the \-session summary when the session yields reusable insight; \-otherwise return only the session page. Schema and required \-keys are enumerated in the user message.";+/// System prompt for batch consolidation. Loaded at compile time+/// from `prompts/batch_consolidate_system.md` so the prompt itself+/// is plain-text-editable + version-controlled as a Markdown file+/// alongside the code. Public so off-tree harnesses (`evals/`) can+/// inspect the exact prompt without duplicating it.+pub const BATCH_SYSTEM_PROMPT: &str = include_str!("../prompts/batch_consolidate_system.md");fn build_request(session_id: SessionId,@@ -475,7 +430,9 @@ fn build_request(// actual ConsolidatedPage JSON, which is plenty for our// ~5 KB max body_markdown. Non-reasoning models stop early// and don't pay extra for the higher cap.- max_tokens: 4000,+ // Generous: 32K covers a multi-page consolidation comfortably.+ // Cheaper to over-allocate than to truncate JSON mid-response.+ max_tokens: 32_000,temperature: Some(0.2),}}@@ -553,17 +510,9 @@ fn short_id(s: &str) -> String {/// [`ObservationKind`] via the observations parameter.const _OBSERVATION_KIND: Option<ObservationKind> = None;-const SYSTEM_PROMPT: &str = "You are the maintainer of a Karpathy-style LLM wiki for a \-software engineer. You receive the chronological observation log of one coding-agent \-session plus the current heuristic page body. Compile a clean, durable markdown page \-that future agents and the user can read to recover context.\n\nRules:\n\-1. Title: short, descriptive (<= 80 chars). No filler.\n\-2. Body: well-formed markdown. Use sections (## Heading) when useful.\n\-3. Focus on decisions made, problems encountered, code/file references, and open \- questions.\n\-4. Do NOT include redundant per-tool-call detail. Aggregate.\n\-5. Do NOT echo timestamps or session ids (frontmatter already has them).\n\-6. Tags: 0-5 short kebab-case tags surfaced to frontmatter.\n";+/// System prompt for single-page consolidation. Loaded at compile+/// time from `prompts/single_consolidate_system.md`.+const SYSTEM_PROMPT: &str = include_str!("../prompts/single_consolidate_system.md");#[cfg(test)]mod tests {diff --git a/crates/ai-memory-consolidate/src/lint.rs b/crates/ai-memory-consolidate/src/lint.rsindex 05084ff7..521af792 100644--- a/crates/ai-memory-consolidate/src/lint.rs+++ b/crates/ai-memory-consolidate/src/lint.rs@@ -13,6 +13,10 @@//! Findings are written to `wiki/_lint/<YYYY-MM-DD>.md` so they're//! grep-able and tracked in git.+/// System prompt for the contradiction-detection lint pass. Loaded+/// at compile time from `prompts/lint_system.md`.+const LINT_SYSTEM_PROMPT: &str = include_str!("../prompts/lint_system.md");+use ai_memory_core::{PagePath, ProjectId, Tier, WorkspaceId};use ai_memory_llm::{ChatMessage, ChatRequest, LlmProvider, Role, complete_structured};use ai_memory_store::{DecayCandidate, ReaderPool};@@ -209,19 +213,14 @@ async fn contradiction_pass(}let request = ChatRequest {- system: Some(- "You audit a personal coding-knowledge wiki for contradictions across pages. \- Return findings only when there's a real conflict; do not invent issues."- .into(),- ),+ system: Some(LINT_SYSTEM_PROMPT.into()),messages: vec![ChatMessage {role: Role::User,content: prompt,}],- // Same reasoning-model headroom rule as the consolidator —- // reasoning models can spend ~2k tokens before any visible- // findings JSON appears.- max_tokens: 4000,+ // Generous output budget so multi-finding reports don't+ // truncate mid-JSON. Same rationale as consolidator/bootstrap.+ max_tokens: 32_000,temperature: Some(0.1),};let report: LintReport = complete_structured(&*provider, request).await?;diff --git a/crates/ai-memory-llm/src/openai_compat.rs b/crates/ai-memory-llm/src/openai_compat.rsindex 379e6dfa..840d1881 100644--- a/crates/ai-memory-llm/src/openai_compat.rs+++ b/crates/ai-memory-llm/src/openai_compat.rs@@ -69,7 +69,20 @@ impl LlmProvider for OpenAiCompatProvider {Ok(v) if v.is_object() => Ok(v),_ => {let Some(slice) = first_json_object(&res.text) else {- debug!(text = %truncate(&res.text, 200), "no balanced JSON object found");+ // Dump enough text to actually see what the model+ // returned. 200 chars truncates inside code fences;+ // 4 KB tells the full story for any reasonable+ // structured-output response. Includes head + tail+ // because some failures truncate the closing brace.+ let head = truncate(&res.text, 2000);+ let tail_start = res.text.len().saturating_sub(2000);+ let tail = &res.text[tail_start..];+ debug!(+ head = %head,+ tail = %tail,+ total_len = res.text.len(),+ "no balanced JSON object found"+ );return Err(LlmError::UnexpectedShape("openai-compat response did not contain a JSON object".into(),));@@ -80,12 +93,35 @@ impl LlmProvider for OpenAiCompatProvider {}}+/// Find the first balanced `{...}` object in a string, skipping+/// braces that appear inside JSON string literals.+///+/// The naive implementation (only count `{` / `}`) breaks when the+/// model returns markdown content inside a JSON string value — the+/// content commonly contains `{` and `}` in code examples,+/// JSON-as-prose, etc. That throws the depth counter off and+/// either truncates the object early or never closes it. This+/// version tracks whether we're inside a `"..."` literal and+/// honours backslash escapes the JSON spec defines.fn first_json_object(s: &str) -> Option<&str> {let start = s.find('{')?;let mut depth = 0_i32;+ let mut in_string = false;+ let mut escape = false;let bytes = s.as_bytes();for (i, &b) in bytes[start..].iter().enumerate() {+ if in_string {+ if escape {+ escape = false;+ } else if b == b'\\' {+ escape = true;+ } else if b == b'"' {+ in_string = false;+ }+ continue;+ }match b {+ b'"' => in_string = true,b'{' => depth += 1,b'}' => {depth -= 1;diff --git a/crates/ai-memory-mcp/prompts/explore_system.md b/crates/ai-memory-mcp/prompts/explore_system.mdnew file mode 100644index 00000000..10105db8--- /dev/null+++ b/crates/ai-memory-mcp/prompts/explore_system.md@@ -0,0 +1,47 @@+You are composing a digest of a software project's long-term+memory for a developer reorienting to the project. You receive a+structured snapshot (JSON) and a `time gap` bucket; your output+is markdown prose.++## Verbosity scales with the gap++- `fresh` (< 1 h ago) — one line. The developer was just here;+ reorient minimally. Example: "Last touched X. No pending work."+- `today` (< 24 h) — 2-4 lines. What was last worked on; pending+ handoffs if any; nothing else.+- `recent` (< 7 days) — 1-2 paragraphs. Summary of what's+ changed; any new rules; pending handoffs; warnings.+- `dormant` (< 30 days) — 3-5 paragraphs. Fuller catchup:+ activity over the window, new rules with one-line+ explanations, pending handoffs spelled out, decay candidates+ if any.+- `stale` (> 30 days) — full briefing. Activity totals, every+ rule surfaced briefly, all pending handoffs, decay+ candidates, warnings about stale knowledge.+- `none` (no prior activity) — one paragraph saying so plus the+ current rule list (if any).++## FAITHFULNESS — the most important rule++Everything in your output MUST be grounded in the snapshot. Do+NOT:++- Invent dates, counts, page titles, rule contents, or warnings+ that aren't in the snapshot data.+- Speculate about *why* things changed unless the snapshot+ includes that context.+- Pad an empty snapshot with generic advice. If the snapshot has+ zero counts and no recent pages, say "no activity recorded+ yet" plainly.++Use the optional `focus` field in the user message to bias+*which parts* of the snapshot you emphasise — but don't+fabricate content to fit the focus topic. If the snapshot has+nothing matching the focus, say so.++## Output format++Plain markdown. Use level-2 headers (`##`) only for the longer+buckets (`dormant`/`stale`). For `fresh`/`today`/`recent` skip+headers entirely. Quote rule titles from the snapshot with+backticks. Never wrap the whole response in code fences.diff --git a/crates/ai-memory-mcp/src/server.rs b/crates/ai-memory-mcp/src/server.rsindex c5aa1d6d..b659ad79 100644--- a/crates/ai-memory-mcp/src/server.rs+++ b/crates/ai-memory-mcp/src/server.rs@@ -747,51 +747,17 @@ fn build_explore_request(role: ai_memory_llm::Role::User,content: user,}],- max_tokens: 1500,+ // memory_explore returns prose, not JSON, so a truncated+ // response is degraded but not unparseable. Still generous+ // so the long `dormant`/`stale` digests don't get cut off.+ max_tokens: 16_000,temperature: Some(0.2),}}-/// System prompt for `memory_explore`. Pure faithfulness rules-/// (mirrors the consolidation system prompt's discipline) + explicit-/// verbosity-vs-gap scaling.-const EXPLORE_SYSTEM_PROMPT: &str = "\-You are composing a digest of a software project's long-term memory \-for a developer reorienting to the project. You receive a structured \-snapshot (JSON) and a `time gap` bucket; your output is markdown \-prose.\n\-\n\-## Verbosity scales with the gap\n\-\n\-- `fresh` (< 1 h ago) — one line. The developer was just here; \- reorient minimally. Example: \"Last touched X. No pending work.\"\n\-- `today` (< 24 h) — 2-4 lines. What was last worked on; pending \- handoffs if any; nothing else.\n\-- `recent` (< 7 days) — 1-2 paragraphs. Summary of what's changed; \- any new rules; pending handoffs; warnings.\n\-- `dormant` (< 30 days) — 3-5 paragraphs. Fuller catchup: \- activity over the window, new rules with one-line explanations, \- pending handoffs spelled out, decay candidates if any.\n\-- `stale` (> 30 days) — full briefing. Activity totals, every rule \- surfaced briefly, all pending handoffs, decay candidates, \- warnings about stale knowledge.\n\-- `none` (no prior activity) — one paragraph saying so plus the \- current rule list (if any).\n\-\n\-## FAITHFULNESS\n\-\n\-Everything in your output MUST be grounded in the snapshot. Do not \-invent dates, counts, or page titles. Do not invent rules or \-warnings that aren't in the data. If the snapshot is empty (zero \-counts, no recent_pages), say so plainly — do not pad with generic \-advice.\n\-\n\-## Format\n\-\n\-Plain markdown. Use level-2 headers (`##`) only for the longer \-buckets (`dormant`/`stale`). For `fresh`/`today`/`recent` skip \-headers entirely. Quote rule titles from the snapshot with \-backticks. Never wrap the whole response in code fences.";+/// System prompt for `memory_explore`. Loaded at compile time from+/// `prompts/explore_system.md`.+const EXPLORE_SYSTEM_PROMPT: &str = include_str!("../prompts/explore_system.md");#[cfg(test)]mod tests {diff --git a/docs/logo.png b/docs/logo.pngnew file mode 100644index 00000000..ff49c9ceBinary files /dev/null and b/docs/logo.png differ