fix(memory): route lessons to LEARNED.md in active guidance

The active rule asked for one fact per file, while init still creates
LEARNED.md as a multi-lesson log and the docs tell users to have agents
update it. The rule now says which goes where: a fact or decision gets
its own file linked from INDEX.md, a lesson from a failure gets a new
heading in LEARNED.md.

Refs Codex review on #384.
This commit is contained in:
Willie
2026-10-04 14:53:39 +08:00
parent 9ea51b1890
commit 464d2fab73
+1 -1
View File
@@ -52,7 +52,7 @@ func ParseMode(s string) (string, error) {
const (
passiveRule = "Update these notes only when the user requests it. When you notice something worth keeping, such as a stated preference, a decision with its reason, or a pitfall you confirmed, say so in one line so the user can ask you to save it."
activeRule = "When a fact is worth keeping across sessions, save it here instead of in this tool's own memory; use tool-specific memory only for things that matter to this tool alone. Save a note when you learn something that will still matter later: a stated user preference, a decision with its reason, or a pitfall you confirmed. Skip one-off task details, guesses, and anything the repository already records. When you are unsure whether something is worth keeping, propose the note to the user and save it only if they agree.\n\nOne fact per file, kebab-case `.md`, first line `# Title`, then the fact and why. Add a `- [Title](file.md)` line with a short hook under `## Notes` in `INDEX.md`. Before writing, search the existing notes and update or remove them instead of adding a duplicate. Never record secrets. Tell the user in one line what you saved."
activeRule = "When a fact is worth keeping across sessions, save it here instead of in this tool's own memory; use tool-specific memory only for things that matter to this tool alone. Save a note when you learn something that will still matter later: a stated user preference, a decision with its reason, or a pitfall you confirmed. Skip one-off task details, guesses, and anything the repository already records. When you are unsure whether something is worth keeping, propose the note to the user and save it only if they agree.\n\nA durable fact or decision gets its own kebab-case `.md` file: first line `# Title`, then the fact and why, plus a `- [Title](file.md)` line with a short hook under `## Notes` in `INDEX.md`. A lesson from a failure goes under a new heading in `LEARNED.md` with its date, context, conclusion, and evidence. Before writing, search the existing notes and update or remove them instead of adding a duplicate. Never record secrets. Tell the user in one line what you saved."
)
// Instructions returns the managed guidance block of the given mode for the