pi-brain 0.1.5 → 0.1.7
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 +2 -2
- package/package.json +1 -2
- package/skills/brain/SKILL.md +13 -5
- package/skills/brain/templates/agents-md.md +1 -1
- package/src/index.ts +13 -21
- package/src/memory-commit.ts +1 -1
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.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Versioned memory extension for the pi coding agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-memory",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"vitest": "^4.0.18"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@mariozechner/pi-coding-agent": "*",
|
|
67
66
|
"@sinclair/typebox": "*"
|
|
68
67
|
},
|
|
69
68
|
"pnpm": {
|
package/skills/brain/SKILL.md
CHANGED
|
@@ -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
|
-
**
|
|
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.
|
|
83
|
+
picture. This means genuine review, not mechanical edits.
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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", (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
292
|
+
frozenStatusSnapshot = null;
|
|
301
293
|
});
|
|
302
294
|
|
|
303
295
|
pi.on("resources_discover", () => ({
|
package/src/memory-commit.ts
CHANGED
|
@@ -65,7 +65,7 @@ export function finalizeMemoryCommit(
|
|
|
65
65
|
const roadmapReminder =
|
|
66
66
|
updateRoadmap === false
|
|
67
67
|
? ""
|
|
68
|
-
: "\n\n**Action required:**
|
|
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
|
}
|