You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/prompt.ts
+82-9Lines changed: 82 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -195,12 +195,24 @@ Do NOT extract:
195
195
- Restatements of what the code obviously does (e.g. "the auth module handles authentication")
196
196
197
197
BREVITY IS CRITICAL — each entry must be concise:
198
-
- content MUST be under 500 words (roughly 2000 characters)
198
+
- content MUST be under 150 words (~600 characters). Capture ONE specific actionable
199
+
insight in 2-3 sentences. Prefer terse technical language.
200
+
- Each "gotcha": one specific trap + its fix in 1-2 sentences
201
+
- Each "architecture": one design decision and its key constraint
199
202
- Focus on the actionable insight, not the full story behind it
200
-
- If a pattern requires more detail, split into multiple focused entries
203
+
- If a pattern requires more detail, split into multiple focused entries (each under 150 words)
201
204
- Omit code examples unless a single short snippet is essential
202
205
- Never include full file contents, large diffs, or complete command outputs
203
206
207
+
PREFER UPDATES OVER CREATES:
208
+
- Before creating a new entry, always check if an existing entry covers the same system
209
+
or component. Update the existing entry rather than creating a new one.
210
+
- When updating, REPLACE the full content with a concise rewrite — do not append to
211
+
the existing content or repeat what was already there.
212
+
- If multiple existing entries cover the same system from different angles (e.g. different
213
+
bugs in the same module), consolidate them: update one with merged insights, delete the
214
+
rest. Fewer, denser entries are better than many scattered ones.
215
+
204
216
crossProject flag:
205
217
- Default is true — most useful knowledge is worth sharing across projects
206
218
- Set crossProject to false for things that are meaningless outside this specific repo (e.g. a config path, a project-local naming convention that conflicts with your usual style)
@@ -211,14 +223,14 @@ Produce a JSON array of operations:
"content": "Concise knowledge entry — under 500 words",
226
+
"content": "Concise knowledge entry — under 150 words",
215
227
"scope": "project" | "global",
216
228
"crossProject": true
217
229
},
218
230
{
219
231
"op": "update",
220
232
"id": "existing-entry-id",
221
-
"content": "Updated content — under 500 words",
233
+
"content": "Updated content — under 150 words",
222
234
"confidence": 0.0-1.0
223
235
},
224
236
{
@@ -241,8 +253,9 @@ export function curatorUser(input: {
241
253
content: string;
242
254
}>;
243
255
}): string{
244
-
constexisting=input.existing.length
245
-
? `Existing knowledge entries (you may update or delete these):\n${input.existing.map((e)=>`- [${e.id}] (${e.category}) ${e.title}: ${e.content}`).join("\n")}`
256
+
constcount=input.existing.length;
257
+
constexisting=count
258
+
? `Existing knowledge entries (${count} total — you may update or delete these):\n${input.existing.map((e)=>`- [${e.id}] (${e.category}) ${e.title}: ${e.content}`).join("\n")}`
246
259
: "No existing knowledge entries.";
247
260
return`${existing}
248
261
@@ -252,7 +265,67 @@ Recent conversation to extract knowledge from:
252
265
${input.messages}
253
266
254
267
---
255
-
IMPORTANT: If any new entries you would create are semantically duplicative of existing entries (same concept, different wording), prefer updating the existing entry rather than creating a new one. Only create new entries for genuinely distinct knowledge.`;
268
+
IMPORTANT:
269
+
1. Prefer updating existing entries over creating new ones. If a new insight refines or
270
+
extends an existing entry on the same topic, update that entry — don't create a new one.
271
+
2. When updating, REPLACE the content with a complete rewrite — never append.
272
+
3. If entries cover the same system from different angles, merge them: update one, delete the rest.
273
+
4. Only create a new entry for genuinely distinct knowledge with no existing home.
274
+
5. Keep all entries under 150 words. If an existing entry is too long, use an update op to trim it.`;
275
+
}
276
+
277
+
/**
278
+
* System prompt for the consolidation pass.
279
+
* Unlike the normal curator (which extracts from conversation), consolidation
280
+
* reviews the FULL entry corpus and aggressively merges/trims/deletes to reduce
281
+
* entry count while preserving the most actionable knowledge.
282
+
*/
283
+
exportconstCONSOLIDATION_SYSTEM=`You are a long-term memory curator performing a consolidation pass. The knowledge base has grown too large and needs to be trimmed.
284
+
285
+
Your goal: reduce the entry count to the target maximum while preserving the most valuable knowledge.
286
+
287
+
CONSOLIDATION RULES:
288
+
1. MERGE related entries — if multiple entries describe the same system, module, or concept
289
+
from different angles (e.g. several bug fixes in the same component), merge them into
290
+
ONE concise entry. Use an "update" op for the surviving entry and "delete" ops for the rest.
291
+
2. TRIM verbose entries — any entry over 150 words must be trimmed to its essential insight.
292
+
Use an "update" op with the rewritten content.
293
+
3. DELETE low-value entries:
294
+
- Stale entries about bugs that have been fixed and no longer need gotcha warnings
295
+
- Entries whose knowledge is fully subsumed by another entry
296
+
- Entries about one-off incidents with no recurring applicability
297
+
- General advice available in any documentation
298
+
4. PRESERVE:
299
+
- Entries describing non-obvious design decisions specific to this codebase
300
+
- Entries about recurring traps that a developer would hit again
301
+
- Entries that capture a hard-won gotcha with a concrete fix
302
+
303
+
OUTPUT: A JSON array of "update" and "delete" ops only. No "create" ops — you are not
304
+
extracting new knowledge, only consolidating existing knowledge.
305
+
306
+
- "update": Replace content with a concise rewrite (under 150 words). Use to merge survivors or trim verbose entries.
307
+
- "delete": Remove entries that are merged, stale, or low-value.
308
+
309
+
Output ONLY valid JSON. No markdown fences, no explanation, no preamble.`;
Produce update/delete ops to reduce entry count to at most ${input.targetMax}. Prioritize merging related entries and trimming verbose ones over outright deletion.`;
256
329
}
257
330
258
331
// Format distillations for injection into the message context.
@@ -287,9 +360,9 @@ export function formatDistillations(
287
360
}
288
361
289
362
// Rough token estimate used for budget-gating knowledge entries.
290
-
// Consistent with gradient.ts: ~4 chars per token.
363
+
// Uses ~3 chars/token (conservative for markdown-heavy technical text).
0 commit comments