kimetsu-pi 0.1.3 → 0.1.4
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 +108 -32
- package/extensions/kimetsu.ts +76 -4
- package/package.json +35 -10
- package/skills/kimetsu-brain/SKILL.md +61 -18
package/README.md
CHANGED
|
@@ -11,50 +11,55 @@
|
|
|
11
11
|
**kimetsu-pi** brings [Kimetsu](https://kimetsu.dev) — a local-first memory brain
|
|
12
12
|
for coding agents — to the [Pi](https://pi.dev) coding agent.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
Kimetsu carries useful lessons between sessions and retrieves relevant project
|
|
15
|
+
knowledge before a task. Storage and retrieval run locally without LLM API calls.
|
|
16
|
+
Automatic lesson extraction can use a configured model; its cost and connectivity
|
|
17
|
+
depend on that configuration.
|
|
18
18
|
|
|
19
19
|
Learn more at **[kimetsu.dev](https://kimetsu.dev)**.
|
|
20
20
|
|
|
21
21
|
## What it is
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
extension points:
|
|
23
|
+
This package connects Kimetsu through Pi's native extension and skill interfaces:
|
|
25
24
|
|
|
26
25
|
- **Extension** (`extensions/kimetsu.ts`) — a TypeScript Pi extension that hooks
|
|
27
|
-
Pi lifecycle events
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
Pi lifecycle events and invokes the `kimetsu` binary to warm, load, and persist
|
|
27
|
+
brain context around each session. Interactive hooks have a 10-second timeout;
|
|
28
|
+
session saving has a
|
|
29
|
+
separate five-minute limit for model-based distillation. If the binary is not
|
|
30
|
+
on `PATH`, every hook silently no-ops and Pi is
|
|
32
31
|
completely unaffected.
|
|
33
32
|
- **Skill** (`skills/kimetsu-brain/SKILL.md`) — a Pi skill that teaches the agent
|
|
34
|
-
|
|
33
|
+
to reuse injected context, correct outdated memories, and cite memories that
|
|
34
|
+
actually helped during a task.
|
|
35
|
+
|
|
36
|
+
## What's new in 0.1.4
|
|
37
|
+
|
|
38
|
+
- Fresh memory per task: older raw injections are excluded from model requests
|
|
39
|
+
and new summaries, including after corrections, queued user messages, and
|
|
40
|
+
branch changes.
|
|
41
|
+
- Session saving gets up to five minutes, while interactive hooks retain their
|
|
42
|
+
10-second limits.
|
|
43
|
+
- Updated guidance for memory reuse, corrections, and usefulness feedback.
|
|
44
|
+
- Verified with Pi 0.85.1 and Kimetsu 2.8.0 on Linux, macOS, and Windows; updated
|
|
45
|
+
dependencies, isolated integration tests, and protected CI and release gates.
|
|
35
46
|
|
|
36
47
|
## Why Kimetsu
|
|
37
48
|
|
|
38
|
-
- **Remembers
|
|
39
|
-
|
|
49
|
+
- **Remembers project knowledge** — conventions, failure patterns, and useful
|
|
50
|
+
commands stay available across sessions.
|
|
40
51
|
- **Speaks first** — proactive session-start digests, episodic resumes, and
|
|
41
52
|
pre-task context, so the agent's first turn already knows your repo.
|
|
42
|
-
- **Learns what helps** —
|
|
43
|
-
|
|
44
|
-
- **
|
|
45
|
-
|
|
46
|
-
- **Stays yours** —
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|---:|---|
|
|
53
|
-
| **89.4%** | LoCoMo, the long-conversation memory benchmark |
|
|
54
|
-
| **83.0%** | LongMemEval, the public long-term-memory benchmark |
|
|
55
|
-
| **73.3%** | BEAM 100K memory benchmark |
|
|
56
|
-
| **13×** | cheaper per solved task ($0.19 vs $2.47 on a Terminal-Bench slice) |
|
|
57
|
-
| **~1M** | memories in ~3 GB RAM with sub-2s retrieval, one SQLite file |
|
|
53
|
+
- **Learns what helps** — citations provide usefulness feedback; maintenance
|
|
54
|
+
identifies memories that may need pruning.
|
|
55
|
+
- **Local retrieval** — lexical search in the default lean build, with optional
|
|
56
|
+
local embeddings and reranking. No LLM API calls for retrieval.
|
|
57
|
+
- **Stays yours** — a local SQLite brain per project, with optional user-wide
|
|
58
|
+
memory. No hosted vector database is required.
|
|
59
|
+
|
|
60
|
+
For Kimetsu's benchmark results, datasets, and evaluation limits, see the
|
|
61
|
+
[core project's benchmark notes](https://github.com/RodCor/kimetsu#benchmarks-vs-other-memory-systems).
|
|
62
|
+
Those evaluate the memory system; this package's CI verifies its Pi integration.
|
|
58
63
|
|
|
59
64
|
## Prerequisites
|
|
60
65
|
|
|
@@ -64,7 +69,8 @@ Install current Pi (Node.js 22.19 or newer):
|
|
|
64
69
|
npm install -g @earendil-works/pi-coding-agent
|
|
65
70
|
```
|
|
66
71
|
|
|
67
|
-
The `kimetsu`
|
|
72
|
+
The `kimetsu` binary must be on `PATH`. Kimetsu 2.8.0 is the tested release for
|
|
73
|
+
this package; the CLI integration requires at least 2.7.0. Install it with:
|
|
68
74
|
|
|
69
75
|
```sh
|
|
70
76
|
npm install -g kimetsu-ai
|
|
@@ -80,12 +86,44 @@ absent, the extension silently no-ops and Pi is unaffected.
|
|
|
80
86
|
pi install npm:kimetsu-pi
|
|
81
87
|
```
|
|
82
88
|
|
|
89
|
+
From the Git project whose memory you want to use, initialize Kimetsu if that
|
|
90
|
+
project does not already have a brain:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
cd /path/to/your/project
|
|
94
|
+
kimetsu init
|
|
95
|
+
kimetsu brain status
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Start Pi in that project, or run `/reload` in an existing Pi session to load the
|
|
99
|
+
extension and skill. Confirm installation with `pi list`.
|
|
100
|
+
|
|
101
|
+
## Upgrade
|
|
102
|
+
|
|
103
|
+
For an installation that follows the latest npm version:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
pi update npm:kimetsu-pi
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
For a pinned installation, select this version explicitly:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
pi install npm:kimetsu-pi@0.1.4
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Then restart Pi or run `/reload`. Pi package updates and Kimetsu CLI updates are
|
|
116
|
+
separate; use `npm install -g kimetsu-ai@latest` if the CLI also needs updating.
|
|
117
|
+
|
|
83
118
|
## What it does on each event
|
|
84
119
|
|
|
85
120
|
| Pi lifecycle event | Kimetsu command run |
|
|
86
121
|
| --- | --- |
|
|
87
122
|
| `session_start` | `kimetsu brain warm` |
|
|
88
123
|
| `before_agent_start` | `kimetsu brain context-hook --warm-on-first-prompt` |
|
|
124
|
+
| `context` | Filters earlier Kimetsu injections out of each model request |
|
|
125
|
+
| `session_before_compact`, `session_before_tree` | Excludes Kimetsu injections from new summaries |
|
|
126
|
+
| `session_tree` | Expires the previous branch's active injection |
|
|
89
127
|
| `agent_end` | `kimetsu brain stop-hook` |
|
|
90
128
|
| `session_shutdown` | `kimetsu brain session-end-hook` |
|
|
91
129
|
|
|
@@ -94,14 +132,52 @@ The extension uses Pi's `SessionManager` identity, so `/new`, `/resume`, and
|
|
|
94
132
|
Pi's persisted JSONL transcript to the stop and session-end hooks, enabling
|
|
95
133
|
Kimetsu's configured distiller and automatic work-episode capture.
|
|
96
134
|
|
|
135
|
+
Only the current task's Kimetsu injection is sent to the model. Older injections
|
|
136
|
+
remain in the saved transcript but are filtered from subsequent model requests,
|
|
137
|
+
including when retrieval returns no context. Ordinary conversation and other
|
|
138
|
+
extensions' messages are preserved. Queued user messages expire the previous
|
|
139
|
+
injection; tool continuations keep it. New compaction and branch summaries omit
|
|
140
|
+
raw Kimetsu injections. This does not rewrite earlier assistant answers or
|
|
141
|
+
existing summaries.
|
|
142
|
+
|
|
143
|
+
Session saving can make two model calls, so it may take longer than retrieval.
|
|
144
|
+
Pi awaits it when closing or switching a session, for up to five minutes; it
|
|
145
|
+
normally finishes sooner. The longer deadline applies only to
|
|
146
|
+
`session-end-hook`. Prompt retrieval, warm-up, and `stop-hook` retain their
|
|
147
|
+
10-second limits. Saving remains best-effort and needs a clean shutdown.
|
|
148
|
+
|
|
149
|
+
The bundled skill teaches the agent to reuse relevant injected context, fetch
|
|
150
|
+
missing evidence, correct existing memories, and cite only memories that
|
|
151
|
+
actually helped. Run `kimetsu brain status` from the project directory to inspect
|
|
152
|
+
the brain. Automatic model-based distillation requires configuration.
|
|
153
|
+
|
|
97
154
|
## Development
|
|
98
155
|
|
|
99
156
|
```sh
|
|
100
|
-
npm
|
|
157
|
+
npm ci
|
|
101
158
|
npm test
|
|
102
159
|
npm run typecheck
|
|
103
160
|
```
|
|
104
161
|
|
|
162
|
+
To run the optional CLI integration test, set `KIMETSU_TEST_BINARY` to the
|
|
163
|
+
absolute path of a Kimetsu 2.8.0+ executable named `kimetsu` (`kimetsu.exe` on
|
|
164
|
+
Windows), then run `npm run test:integration`. This command fails if the binary
|
|
165
|
+
is missing. It creates an isolated temporary brain, uses
|
|
166
|
+
lexical retrieval without model calls, and verifies correction, context
|
|
167
|
+
filtering, citation, and session persistence.
|
|
168
|
+
|
|
169
|
+
The fixture anchors a new Git repository and gives subprocesses temporary homes,
|
|
170
|
+
caches, and user-brain paths. It removes inherited Git/Kimetsu overrides and
|
|
171
|
+
credentials before initialization. Never run integration commands against your
|
|
172
|
+
normal project or home brain.
|
|
173
|
+
|
|
174
|
+
CI requires the real CLI test on Linux, macOS, and Windows using checksum-pinned
|
|
175
|
+
Kimetsu 2.8.0 binaries and the minimum supported Node version. The `required checks`
|
|
176
|
+
gate also requires typechecking, tests, the dependency audit, and package dry-run.
|
|
177
|
+
Release tags must match the package version and point to a commit on `main` with
|
|
178
|
+
successful CI. Wait for that commit's CI before tagging; a release started too
|
|
179
|
+
early must be rerun after CI passes.
|
|
180
|
+
|
|
105
181
|
## Links
|
|
106
182
|
|
|
107
183
|
- **Website & docs:** [kimetsu.dev](https://kimetsu.dev)
|
package/extensions/kimetsu.ts
CHANGED
|
@@ -14,11 +14,16 @@
|
|
|
14
14
|
// crash, unparseable output. Kimetsu is a sidecar — it must never break Pi.
|
|
15
15
|
|
|
16
16
|
import { spawn } from "node:child_process";
|
|
17
|
+
import { randomUUID } from "node:crypto";
|
|
17
18
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
18
19
|
|
|
19
|
-
/**
|
|
20
|
+
/** Interactive hooks must not leave a turn waiting on a hung binary. */
|
|
20
21
|
const EXEC_TIMEOUT_MS = 10000;
|
|
21
22
|
|
|
23
|
+
/** Session saving may distill lessons and an episode in two model calls
|
|
24
|
+
* (120s each by default). Leave time for both plus local persistence. */
|
|
25
|
+
const SESSION_SAVE_TIMEOUT_MS = 300000;
|
|
26
|
+
|
|
22
27
|
/** Fallback session id when Pi's context does not expose one. Stable per process,
|
|
23
28
|
* which is what the brain's per-session dedupe and refractory windows need. */
|
|
24
29
|
const FALLBACK_SESSION_ID = `pi-${process.pid}`;
|
|
@@ -30,7 +35,7 @@ const FALLBACK_SESSION_ID = `pi-${process.pid}`;
|
|
|
30
35
|
* stdout is PIPED, not ignored: the context hook communicates entirely through
|
|
31
36
|
* it. stderr stays ignored so diagnostics never mix into the parsed payload.
|
|
32
37
|
*/
|
|
33
|
-
function kimetsuRun(args: string[], input?: string): Promise<string> {
|
|
38
|
+
function kimetsuRun(args: string[], input?: string, timeoutMs = EXEC_TIMEOUT_MS): Promise<string> {
|
|
34
39
|
return new Promise((resolve) => {
|
|
35
40
|
let settled = false;
|
|
36
41
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -52,7 +57,7 @@ function kimetsuRun(args: string[], input?: string): Promise<string> {
|
|
|
52
57
|
timer = setTimeout(() => {
|
|
53
58
|
child.kill();
|
|
54
59
|
done();
|
|
55
|
-
},
|
|
60
|
+
}, timeoutMs);
|
|
56
61
|
if (typeof timer.unref === "function") timer.unref();
|
|
57
62
|
|
|
58
63
|
child.stdout?.setEncoding("utf8");
|
|
@@ -147,11 +152,17 @@ function workspaceArgs(ctx: any): string[] {
|
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
export default function (pi: ExtensionAPI) {
|
|
155
|
+
// Pi persists injected messages, including display:false messages. Only the
|
|
156
|
+
// current task's injection belongs in future model calls. A unique marker
|
|
157
|
+
// survives Pi's message cloning without trusting content or timestamps.
|
|
158
|
+
let activeContext: { id: string; sessionId: string } | undefined;
|
|
159
|
+
|
|
150
160
|
// session_start fires once when Pi starts up or a new session begins.
|
|
151
161
|
// Warming spawns the embedder daemon so the first real retrieval is semantic
|
|
152
162
|
// rather than falling back to lexical FTS.
|
|
153
163
|
// (`brain warm` takes no --workspace: it resolves the project from its cwd.)
|
|
154
164
|
pi.on("session_start", async (_event, _ctx) => {
|
|
165
|
+
activeContext = undefined;
|
|
155
166
|
await kimetsuRun(["brain", "warm"]);
|
|
156
167
|
});
|
|
157
168
|
|
|
@@ -161,14 +172,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
161
172
|
// --warm-on-first-prompt folds the repo digest and episodic resume into the
|
|
162
173
|
// first turn of each session.
|
|
163
174
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
175
|
+
const request = { id: randomUUID(), sessionId: sessionIdOf(ctx) };
|
|
176
|
+
// Expire the last task immediately, even if retrieval is empty or fails.
|
|
177
|
+
activeContext = request;
|
|
164
178
|
const payload = JSON.stringify({
|
|
165
|
-
session_id:
|
|
179
|
+
session_id: request.sessionId,
|
|
166
180
|
prompt: typeof event?.prompt === "string" ? event.prompt : "",
|
|
167
181
|
});
|
|
168
182
|
const stdout = await kimetsuRun(
|
|
169
183
|
["brain", "context-hook", "--warm-on-first-prompt", ...workspaceArgs(ctx)],
|
|
170
184
|
payload,
|
|
171
185
|
);
|
|
186
|
+
// A session switch or a newer prompt can supersede an in-flight request.
|
|
187
|
+
if (activeContext !== request) return;
|
|
172
188
|
const content = parseAdditionalContext(stdout);
|
|
173
189
|
if (content === undefined) return; // nothing relevant — zero tokens
|
|
174
190
|
return {
|
|
@@ -176,10 +192,64 @@ export default function (pi: ExtensionAPI) {
|
|
|
176
192
|
customType: "kimetsu-brain",
|
|
177
193
|
content,
|
|
178
194
|
display: false,
|
|
195
|
+
details: { kimetsuContextId: request.id },
|
|
179
196
|
},
|
|
180
197
|
};
|
|
181
198
|
});
|
|
182
199
|
|
|
200
|
+
pi.on("context", async (event, ctx) => {
|
|
201
|
+
const context = activeContext;
|
|
202
|
+
const currentIndex = context && context.sessionId === sessionIdOf(ctx)
|
|
203
|
+
? event.messages.findIndex((message) => {
|
|
204
|
+
if (message.role !== "custom" || message.customType !== "kimetsu-brain") return false;
|
|
205
|
+
const details = message.details as { kimetsuContextId?: unknown } | undefined;
|
|
206
|
+
return details?.kimetsuContextId === context.id;
|
|
207
|
+
})
|
|
208
|
+
: -1;
|
|
209
|
+
// Queued steering/follow-up messages bypass before_agent_start. Expire
|
|
210
|
+
// the old injection when a newer user message arrives; tool results alone
|
|
211
|
+
// do not end the current task's context.
|
|
212
|
+
if (currentIndex >= 0 && event.messages.some((message, index) =>
|
|
213
|
+
index > currentIndex && message.role === "user"
|
|
214
|
+
)) activeContext = undefined;
|
|
215
|
+
|
|
216
|
+
// Filter the model's copy only; preserve the persisted session history.
|
|
217
|
+
return {
|
|
218
|
+
messages: event.messages.filter((message, index) =>
|
|
219
|
+
message.role !== "custom" || message.customType !== "kimetsu-brain"
|
|
220
|
+
|| (activeContext !== undefined && index === currentIndex)
|
|
221
|
+
),
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
pi.on("session_before_compact", async (event) => {
|
|
226
|
+
// Summarization bypasses the context event. Do not turn retrieved evidence
|
|
227
|
+
// into a durable summary that could outlive a correction or invalidation.
|
|
228
|
+
event.preparation.messagesToSummarize = event.preparation.messagesToSummarize.filter(
|
|
229
|
+
(message) => message.role !== "custom" || message.customType !== "kimetsu-brain",
|
|
230
|
+
);
|
|
231
|
+
event.preparation.turnPrefixMessages = event.preparation.turnPrefixMessages.filter(
|
|
232
|
+
(message) => message.role !== "custom" || message.customType !== "kimetsu-brain",
|
|
233
|
+
);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
pi.on("session_before_tree", async (event) => {
|
|
237
|
+
// Pi retains a reference to this temporary summary input array, so filter
|
|
238
|
+
// in place. The persisted session entries themselves are left untouched.
|
|
239
|
+
const entries = event.preparation.entriesToSummarize;
|
|
240
|
+
let kept = 0;
|
|
241
|
+
for (const entry of entries) {
|
|
242
|
+
if (entry.type !== "custom_message" || entry.customType !== "kimetsu-brain") {
|
|
243
|
+
entries[kept++] = entry;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
entries.length = kept;
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
pi.on("session_tree", async () => {
|
|
250
|
+
activeContext = undefined;
|
|
251
|
+
});
|
|
252
|
+
|
|
183
253
|
// agent_end fires after the LLM turn completes (maps to Kimetsu stop-hook).
|
|
184
254
|
pi.on("agent_end", async (event, ctx) => {
|
|
185
255
|
await kimetsuRun(
|
|
@@ -190,9 +260,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
190
260
|
|
|
191
261
|
// session_shutdown fires on clean session close (maps to session-end-hook).
|
|
192
262
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
263
|
+
activeContext = undefined;
|
|
193
264
|
await kimetsuRun(
|
|
194
265
|
["brain", "session-end-hook", ...workspaceArgs(ctx)],
|
|
195
266
|
lifecyclePayload(ctx),
|
|
267
|
+
SESSION_SAVE_TIMEOUT_MS,
|
|
196
268
|
);
|
|
197
269
|
});
|
|
198
270
|
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kimetsu-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Kimetsu brain as a Pi.dev package — local-first, cross-session memory for the Pi coding agent that gets sharper every run.",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi",
|
|
8
|
+
"kimetsu",
|
|
9
|
+
"memory",
|
|
10
|
+
"brain",
|
|
11
|
+
"rag",
|
|
12
|
+
"mcp",
|
|
13
|
+
"extension",
|
|
14
|
+
"skill"
|
|
15
|
+
],
|
|
6
16
|
"homepage": "https://kimetsu.dev",
|
|
7
|
-
"repository": {
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/RodCor/kimetsu-pi.git"
|
|
20
|
+
},
|
|
8
21
|
"license": "MIT OR Apache-2.0",
|
|
9
22
|
"type": "module",
|
|
10
23
|
"pi": {
|
|
11
|
-
"extensions": [
|
|
12
|
-
|
|
24
|
+
"extensions": [
|
|
25
|
+
"./extensions"
|
|
26
|
+
],
|
|
27
|
+
"skills": [
|
|
28
|
+
"./skills"
|
|
29
|
+
],
|
|
13
30
|
"image": "https://raw.githubusercontent.com/RodCor/kimetsu/main/docs/assets/kimetsu-logo.png"
|
|
14
31
|
},
|
|
15
|
-
"files": [
|
|
16
|
-
|
|
32
|
+
"files": [
|
|
33
|
+
"extensions/",
|
|
34
|
+
"skills/",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22.19.0"
|
|
40
|
+
},
|
|
17
41
|
"scripts": {
|
|
18
42
|
"typecheck": "tsc --noEmit",
|
|
19
|
-
"test": "vitest run"
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:integration": "node scripts/test-integration.mjs"
|
|
20
45
|
},
|
|
21
46
|
"devDependencies": {
|
|
22
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
47
|
+
"@earendil-works/pi-coding-agent": "^0.85.1",
|
|
23
48
|
"@types/node": "^26.0.0",
|
|
24
49
|
"typescript": "^7.0.0",
|
|
25
|
-
"vitest": "
|
|
50
|
+
"vitest": "5.0.0"
|
|
26
51
|
},
|
|
27
52
|
"peerDependencies": {
|
|
28
53
|
"@earendil-works/pi-coding-agent": "*"
|
|
@@ -1,21 +1,64 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kimetsu-brain
|
|
3
|
-
description: Use
|
|
3
|
+
description: Use when Pi tasks benefit from prior session knowledge, durable lessons, memory corrections, or feedback on helpful memories.
|
|
4
4
|
---
|
|
5
|
-
Kimetsu is a persistent
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
Kimetsu is a persistent memory sidecar accessed through the `kimetsu` CLI.
|
|
6
|
+
Run commands from the relevant project directory. If the binary is unavailable,
|
|
7
|
+
note the absence and continue normally.
|
|
8
|
+
|
|
9
|
+
## Use the context already provided
|
|
10
|
+
|
|
11
|
+
The Pi extension retrieves context before each task. Read that injection first.
|
|
12
|
+
When it covers the current question, proceed without repeating the same lookup.
|
|
13
|
+
Use `kimetsu brain context "<specific question>"` when no useful context was
|
|
14
|
+
injected, the task changes, or a missing detail or correction needs fresh evidence.
|
|
15
|
+
An empty result is a reason to inspect the repository, not repeat the same query.
|
|
16
|
+
|
|
17
|
+
Memory is evidence from earlier work. Check conflicts against current files and
|
|
18
|
+
the user's instructions. Respect project, environment, and version boundaries;
|
|
19
|
+
partial or conflicting evidence does not justify filling gaps with assumptions.
|
|
20
|
+
|
|
21
|
+
## Record and correct durable lessons
|
|
22
|
+
|
|
23
|
+
After verifying a reusable lesson, record it with
|
|
24
|
+
`kimetsu brain memory add --scope project --kind <kind> "<lesson>"`.
|
|
25
|
+
Choose `fact`, `preference`, `convention`, `command`, or `failure_pattern`.
|
|
26
|
+
Include the subject and any environment/version limits in the text.
|
|
27
|
+
|
|
28
|
+
For a correction to an existing claim, update its actual memory ID instead of
|
|
29
|
+
adding a contradictory duplicate:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
kimetsu brain memory edit <memory-id> --text "Production gateway port is 4000. Development gateway port remains 3000."
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Preserve still-valid parts of the claim. Different environments or historical
|
|
36
|
+
versions can both be valid; a production correction does not retire development
|
|
37
|
+
guidance. When the entire memory is obsolete or false, use
|
|
38
|
+
`kimetsu brain memory invalidate <memory-id> --reason "<verified reason>"`.
|
|
39
|
+
|
|
40
|
+
Find actual IDs with `kimetsu brain context "<specific question>" --json` or
|
|
41
|
+
`kimetsu brain memory list --json`; match the text and scope before editing,
|
|
42
|
+
invalidating, or citing. For a `memory:<id>` expansion handle, use only `<id>`.
|
|
43
|
+
Never invent an ID or treat a file capsule as a memory.
|
|
44
|
+
The edit/invalidate commands above operate on the current workspace brain.
|
|
45
|
+
Listings may also include portable user-brain memories; those commands cannot
|
|
46
|
+
correct them. For a user-brain claim, report the correction and this limitation
|
|
47
|
+
instead of claiming the portable memory was updated.
|
|
48
|
+
|
|
49
|
+
## Credit explicit usefulness
|
|
50
|
+
|
|
51
|
+
When a particular memory materially helped, record that reliance:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
kimetsu brain cite --memory-id <memory-id> --query "<task it helped with>" --note "<how it helped>"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Cite only memories actually used. Being injected, or having tests pass, is not
|
|
58
|
+
enough to credit a memory. A citation records usefulness, not proof of truth;
|
|
59
|
+
correct wrong claims using the commands above. Do not cite unused memories or
|
|
60
|
+
repeat credit for the same use.
|
|
61
|
+
|
|
62
|
+
`kimetsu brain status` reports initialization, accepted memories, and pending
|
|
63
|
+
proposals. Automatic session saving is separate from these deliberate actions;
|
|
64
|
+
model-based lesson distillation requires a configured distiller.
|