pi-brain 0.1.4 → 0.1.5

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,6 +6,8 @@
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)
10
+
9
11
  ## Getting Started
10
12
 
11
13
  ```bash
@@ -14,7 +16,7 @@ pi install npm:pi-brain
14
16
 
15
17
  Open pi in any project and say "initialize Brain" (or run `/skill:brain`). The agent creates `.memory/` and starts remembering.
16
18
 
17
- That's it. The agent decides when to commit, branch, and merge — you don't need to manage anything.
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.
18
20
 
19
21
  ## How It Works
20
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-brain",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Versioned memory extension for the pi coding agent",
5
5
  "keywords": [
6
6
  "agent-memory",
@@ -76,6 +76,20 @@ For deep retrieval, use `read` directly:
76
76
  A subagent handles commit distillation — it reads your `log.md` and prior commits,
77
77
  then produces the structured commit entry. You just provide a good `summary` string.
78
78
 
79
+ ## After Every Commit
80
+
81
+ **Update `.memory/main.md` to reflect the current state.** The roadmap is the first
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:
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
88
+
89
+ For trivial commits that don't change the project's state, decisions, or milestones
90
+ (e.g., minor refactors, typo fixes), you can pass `update_roadmap: false` to skip
91
+ the reminder. Most commits should update the roadmap.
92
+
79
93
  ## When to Branch
80
94
 
81
95
  - You want to explore an alternative approach without contaminating current thinking
@@ -40,6 +40,17 @@ Each commit in `commits.md` has three blocks:
40
40
 
41
41
  The latest commit always contains a self-contained summary of the full branch history.
42
42
 
43
+ ## When to Commit
44
+
45
+ Call `memory_commit` when one of these is true:
46
+
47
+ - You reached a stable decision or understanding worth preserving.
48
+ - You finished an exploration branch with a clear conclusion.
49
+ - You are about to change direction significantly.
50
+ - You completed meaningful progress and are about to end the session.
51
+ - The extension warns that `log.md` is getting large.
52
+ - You are about to claim the task is complete or hand off to another agent.
53
+
43
54
  ## Conventions
44
55
 
45
56
  - **Agent-driven**: You decide when to commit, branch, and merge
@@ -47,3 +58,4 @@ The latest commit always contains a self-contained summary of the full branch hi
47
58
  - **Rolling summaries**: Each commit re-synthesizes all prior progress
48
59
  - **No direct log.md writes**: The extension maintains log.md automatically
49
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.
package/src/index.ts CHANGED
@@ -127,12 +127,10 @@ export default function activate(pi: ExtensionAPI) {
127
127
  description:
128
128
  "Manage memory branches. Actions: create (new branch), switch (change active branch), merge (synthesize branch into current).",
129
129
  parameters: Type.Object({
130
- action: Type.Union(
131
- [Type.Literal("create"), Type.Literal("switch"), Type.Literal("merge")],
132
- {
133
- description: 'Action to perform: "create", "switch", or "merge"',
134
- }
135
- ),
130
+ action: Type.String({
131
+ enum: ["create", "switch", "merge"],
132
+ description: 'Action to perform: "create", "switch", or "merge"',
133
+ }),
136
134
  name: Type.Optional(
137
135
  Type.String({ description: "Branch name (required for create)" })
138
136
  ),
@@ -180,7 +178,12 @@ export default function activate(pi: ExtensionAPI) {
180
178
  description: "Checkpoint a milestone in agent memory.",
181
179
  parameters: Type.Object({
182
180
  summary: Type.String({ description: "Short summary of this checkpoint" }),
183
- update_roadmap: Type.Optional(Type.Boolean()),
181
+ update_roadmap: Type.Optional(
182
+ Type.Boolean({
183
+ description:
184
+ "Update .memory/main.md after commit. Defaults to true — set false to skip for trivial commits.",
185
+ })
186
+ ),
184
187
  }),
185
188
  async execute(_toolCallId, params, signal, _onUpdate, ctx) {
186
189
  if (
@@ -214,7 +217,8 @@ export default function activate(pi: ExtensionAPI) {
214
217
  commitContent,
215
218
  state,
216
219
  branchManager,
217
- ctx.cwd
220
+ ctx.cwd,
221
+ params.update_roadmap
218
222
  );
219
223
 
220
224
  setBrainFooterStatus(ctx, state, branchManager);
@@ -34,7 +34,8 @@ export function finalizeMemoryCommit(
34
34
  commitContent: string,
35
35
  state: MemoryState,
36
36
  branches: BranchManager,
37
- projectDir: string
37
+ projectDir: string,
38
+ updateRoadmap?: boolean
38
39
  ): string {
39
40
  const branch = state.activeBranch;
40
41
  const hash = generateHash();
@@ -60,5 +61,11 @@ export function finalizeMemoryCommit(
60
61
  const status = buildStatusView(state, branches, projectDir, {
61
62
  compact: true,
62
63
  });
63
- return `${resultText}\n\n${status}`;
64
+
65
+ const roadmapReminder =
66
+ updateRoadmap === false
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.";
69
+
70
+ return `${resultText}\n\n${status}${roadmapReminder}`;
64
71
  }