pi-brain 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Versioned memory for the [pi coding agent](https://github.com/badlogic/pi-mono). Agents commit decisions and reasoning to a `.memory/` directory, preserving context across sessions, compactions, and model switches.
8
8
 
9
- Credit: This project is my implementation for Pi of this paper [Git Context Controller: Manage the Context of LLM-based Agents like Git](https://arxiv.org/html/2508.00031v1)
9
+ Credit: This project is my implementation for Pi of this paper [Git Context Controller: Manage the Context of LLM-based Agents like Git](https://arxiv.org/html/2508.00031v1)
10
10
 
11
11
  ## Getting Started
12
12
 
@@ -16,7 +16,7 @@ pi install npm:pi-brain
16
16
 
17
17
  Open pi in any project and say "initialize Brain" (or run `/skill:brain`). The agent creates `.memory/` and starts remembering.
18
18
 
19
- That's it. The agent decides when to commit, branch, and merge — you don't **need** to manage anything. However, you can always prompt the agent to remember something specific if you'd like.
19
+ That's it. The agent decides when to commit, branch, and merge — you don't **need** to manage anything. However, you can always prompt the agent to remember something specific if you'd like.
20
20
 
21
21
  ## How It Works
22
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-brain",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Versioned memory extension for the pi coding agent",
5
5
  "keywords": [
6
6
  "agent-memory",
@@ -78,13 +78,21 @@ then produces the structured commit entry. You just provide a good `summary` str
78
78
 
79
79
  ## After Every Commit
80
80
 
81
- **Update `.memory/main.md` to reflect the current state.** The roadmap is the first
81
+ **Re-read `.memory/main.md` and rewrite stale sections.** The roadmap is the first
82
82
  thing a new session reads — if it's stale, every future session starts with a wrong
83
- picture. After `memory_commit` returns, review and update:
83
+ picture. This means genuine review, not mechanical edits.
84
84
 
85
- - **Current State** section — reflect what's actually true now
86
- - **Key Decisions Made** — add any new decisions from this commit
87
- - **Milestones** move completed items, add new planned ones
85
+ After `memory_commit` returns:
86
+
87
+ 1. Read `.memory/main.md` in full.
88
+ 2. Rewrite the **Current State** section to describe what is true _right now_ — remove
89
+ historical context that has migrated to Key Decisions or Milestones.
90
+ 3. Add any new entries to **Key Decisions Made**.
91
+ 4. Move completed items in **Milestones** and add new planned ones.
92
+ 5. Remove or rewrite anything a new reader would find misleading.
93
+
94
+ The goal is curation, not accumulation. A reader of Current State should understand
95
+ the project as it exists today without wading through history.
88
96
 
89
97
  For trivial commits that don't change the project's state, decisions, or milestones
90
98
  (e.g., minor refactors, typo fixes), you can pass `update_roadmap: false` to skip
@@ -58,4 +58,4 @@ Call `memory_commit` when one of these is true:
58
58
  - **Rolling summaries**: Each commit re-synthesizes all prior progress
59
59
  - **No direct log.md writes**: The extension maintains log.md automatically
60
60
  - **Status is automatic**: Memory status is injected at session start and appended to tool results (compact/truncated when large; use `read .memory/main.md` for full roadmap)
61
- - **Keep main.md current**: After every commit, update `.memory/main.md` to reflect the new state current state, decisions, and milestones. The roadmap is the first thing new sessions read; stale roadmaps cause wrong orientation. For trivial commits that don't change project state (e.g., minor refactors), pass `update_roadmap: false` to skip the reminder.
61
+ - **Keep main.md current**: After every commit, re-read `.memory/main.md` in full and rewrite stale sections. Current State should describe what is true _right now_ remove historical context that belongs in Key Decisions or Milestones. The goal is curation, not accumulation. For trivial commits that don't change project state, pass `update_roadmap: false` to skip the reminder.
package/src/index.ts CHANGED
@@ -101,7 +101,7 @@ function resolveSkillPath(): string {
101
101
  export default function activate(pi: ExtensionAPI) {
102
102
  let state: MemoryState | null = null;
103
103
  let branchManager: BranchManager | null = null;
104
- let statusInjected = false;
104
+ let frozenStatusSnapshot: string | null = null;
105
105
 
106
106
  function tryLoad(ctx: ExtensionContext): boolean {
107
107
  if (isMemoryReady(state, branchManager)) {
@@ -230,7 +230,7 @@ export default function activate(pi: ExtensionAPI) {
230
230
  state = new MemoryState(ctx.cwd);
231
231
  state.load();
232
232
  branchManager = new BranchManager(ctx.cwd);
233
- statusInjected = false;
233
+ frozenStatusSnapshot = null;
234
234
 
235
235
  if (!state.isInitialized) {
236
236
  setBrainFooterStatus(ctx, state, branchManager);
@@ -253,7 +253,7 @@ export default function activate(pi: ExtensionAPI) {
253
253
  });
254
254
 
255
255
  pi.on("session_switch", (_event, ctx) => {
256
- statusInjected = false;
256
+ frozenStatusSnapshot = null;
257
257
 
258
258
  state = new MemoryState(ctx.cwd);
259
259
  state.load();
@@ -266,11 +266,7 @@ export default function activate(pi: ExtensionAPI) {
266
266
  setBrainFooterStatus(ctx, state, branchManager);
267
267
  });
268
268
 
269
- pi.on("before_agent_start", (_event: BeforeAgentStartEvent, ctx) => {
270
- if (statusInjected) {
271
- return;
272
- }
273
-
269
+ pi.on("before_agent_start", (event: BeforeAgentStartEvent, ctx) => {
274
270
  if (
275
271
  !tryLoad(ctx) ||
276
272
  !isMemoryReady(state, branchManager) ||
@@ -279,25 +275,21 @@ export default function activate(pi: ExtensionAPI) {
279
275
  return;
280
276
  }
281
277
 
282
- statusInjected = true;
278
+ if (frozenStatusSnapshot === null) {
279
+ frozenStatusSnapshot = buildStatusView(state, branchManager, ctx.cwd, {
280
+ compact: true,
281
+ roadmapCharLimit: BEFORE_AGENT_START_ROADMAP_CHAR_LIMIT,
282
+ branchLimit: BEFORE_AGENT_START_BRANCH_LIMIT,
283
+ });
284
+ }
283
285
 
284
- const status = buildStatusView(state, branchManager, ctx.cwd, {
285
- compact: true,
286
- roadmapCharLimit: BEFORE_AGENT_START_ROADMAP_CHAR_LIMIT,
287
- branchLimit: BEFORE_AGENT_START_BRANCH_LIMIT,
288
- });
289
286
  return {
290
- message: {
291
- customType: "brain-status",
292
- content: status,
293
- display: true,
294
- details: {},
295
- },
287
+ systemPrompt: `${event.systemPrompt}\n\n${frozenStatusSnapshot}`,
296
288
  };
297
289
  });
298
290
 
299
291
  pi.on("session_compact", () => {
300
- statusInjected = false;
292
+ frozenStatusSnapshot = null;
301
293
  });
302
294
 
303
295
  pi.on("resources_discover", () => ({
@@ -65,7 +65,7 @@ export function finalizeMemoryCommit(
65
65
  const roadmapReminder =
66
66
  updateRoadmap === false
67
67
  ? ""
68
- : "\n\n**Action required:** Update `.memory/main.md` to reflect this commit current state, decisions, and milestones. The roadmap is the first thing new sessions read.";
68
+ : "\n\n**Action required:** Re-read `.memory/main.md` in full and rewrite stale sections. Current State should describe what is true right now curate, don't just append.";
69
69
 
70
70
  return `${resultText}\n\n${status}${roadmapReminder}`;
71
71
  }