Skip to content

Commit ad312b1

Browse files
Claudeclaude
authored andcommitted
feat: add first-session nudge to session_start display (OD-750)
When no prior sessions exist, appends a one-time nudge block to the display output suggesting patterns the agent should save to its PMEM. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4ae9fec commit ad312b1

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
</p>
44

55
<p align="center">
6-
<a href="https://www.npmjs.com/package/gitmem-mcp"><img src="https://img.shields.io/npm/v/gitmem-mcp?style=flat-square&color=ed1e25&label=npm" alt="npm version" /></a>
6+
<a href="https://www.npmjs.com/package/gitmem-mcp"><img src="https://img.shields.io/npm/v/gitmem-mcp?style=flat-square&color=c41920&label=npm" alt="npm version" /></a>
77
<a href="https://www.npmjs.com/package/gitmem-mcp"><img src="https://img.shields.io/npm/dm/gitmem-mcp?style=flat-square&color=333333&label=downloads" alt="npm downloads" /></a>
8-
<a href="https://github.com/gitmem-dev/gitmem/blob/main/LICENSE"><img src="https://img.shields.io/github/license/gitmem-dev/gitmem?style=flat-square&color=ed1e25" alt="MIT License" /></a>
8+
<a href="https://github.com/gitmem-dev/gitmem/blob/main/LICENSE"><img src="https://img.shields.io/github/license/gitmem-dev/gitmem?style=flat-square&color=c41920" alt="MIT License" /></a>
99
<a href="https://github.com/gitmem-dev/gitmem/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/gitmem-dev/gitmem/ci.yml?style=flat-square&color=333333&label=build" alt="Build" /></a>
10-
<img src="https://img.shields.io/badge/node-%3E%3D22-ed1e25?style=flat-square" alt="Node.js >= 22" />
10+
<img src="https://img.shields.io/badge/node-%3E%3D18-c41920?style=flat-square" alt="Node.js >= 18" />
1111
</p>
1212

1313
<p align="center">

src/tools/session-start.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ const CLOSING_PAYLOAD_SCHEMA: Record<string, unknown> = {
7474
decisions: [],
7575
};
7676

77+
const FIRST_SESSION_NUDGE = [
78+
"",
79+
"Welcome to gitmem. Patterns that improve the experience:",
80+
"",
81+
" - session_start: once per session — if a hook triggers it, don't repeat",
82+
" - Display protocol: echo tool results verbatim, including ANSI formatting",
83+
" - recall() before consequential actions (deploys, issues, agent spawns)",
84+
" - Read .gitmem/ state before session close — survives context compaction",
85+
" - Search gitmem before filesystem exploration — memory > re-discovery",
86+
" - Create learning entries after significant work, before closing",
87+
"",
88+
"Save these to your persistent memory (MEMORY.md) so they carry forward.",
89+
].join("\n");
90+
7791
// Supabase record types
7892
interface SessionRecord {
7993
id: string;
@@ -567,7 +581,8 @@ async function sessionStartFree(
567581
project,
568582
performance,
569583
};
570-
freeResult.display = formatStartDisplay(freeResult);
584+
const isFirstSession = !isResuming && !lastSession;
585+
freeResult.display = formatStartDisplay(freeResult, undefined, isFirstSession);
571586

572587
// Write display to per-session dir
573588
try {
@@ -810,7 +825,7 @@ function stripThreadPrefix(text: string): string {
810825
return text.replace(/^t-[a-f0-9]+:\s*/i, "");
811826
}
812827

813-
function formatStartDisplay(result: SessionStartResult, displayInfoMap?: Map<string, ThreadDisplayInfo>): string {
828+
function formatStartDisplay(result: SessionStartResult, displayInfoMap?: Map<string, ThreadDisplayInfo>, isFirstSession?: boolean): string {
814829
const visual: string[] = [];
815830

816831
// Line 1: branded product line + session state
@@ -863,6 +878,11 @@ function formatStartDisplay(result: SessionStartResult, displayInfoMap?: Map<str
863878
visual.push("No threads or decisions.");
864879
}
865880

881+
// First-session nudge — agent sees this once, internalizes to PMEM
882+
if (isFirstSession) {
883+
visual.push(FIRST_SESSION_NUDGE);
884+
}
885+
866886
const visualBlock = visual.join("\n");
867887

868888
// ── Display-first layout ──
@@ -1086,7 +1106,8 @@ export async function sessionStart(
10861106
for (const info of threadDisplayInfo) {
10871107
displayInfoMap.set(info.thread.id, info);
10881108
}
1089-
result.display = formatStartDisplay(result, displayInfoMap);
1109+
const isFirstSession = !isResuming && !slimLastSession;
1110+
result.display = formatStartDisplay(result, displayInfoMap, isFirstSession);
10901111

10911112
// Write display to per-session dir
10921113
try {

0 commit comments

Comments
 (0)