knowmind 0.2.0 → 0.3.0
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/CHANGELOG.md +10 -0
- package/bin/knowmind.js +17 -1
- package/package.json +1 -1
- package/src/init.js +33 -3
- package/src/status.js +24 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Knowmind CLI — Änderungen
|
|
2
2
|
|
|
3
|
+
## 0.3.0 (2026-07-16)
|
|
4
|
+
|
|
5
|
+
**`knowmind status`: Sitzungs-Zähler + sichtbares Flackern**
|
|
6
|
+
- Die Statusline zeigt jetzt, wie viele Erinnerungen in der laufenden Sitzung
|
|
7
|
+
abgerufen wurden — als eigenes, farblich hervorgehobenes Lebenszeichen.
|
|
8
|
+
- Die grüne LED flackert bei Aktivität jetzt sichtbar: `knowmind init --client
|
|
9
|
+
claude-code` richtet die Statusleiste mit periodischem Neuzeichnen ein
|
|
10
|
+
(Claude Code ab v2.1.97). Ohne das rendert Claude Code die Statusleiste nur
|
|
11
|
+
bei Ereignissen, sodass eine Animation nicht sichtbar würde.
|
|
12
|
+
|
|
3
13
|
## 0.2.0 (2026-07-16)
|
|
4
14
|
|
|
5
15
|
**Neu: `knowmind status` — sichtbares Lebenszeichen des Gedächtnisses**
|
package/bin/knowmind.js
CHANGED
|
@@ -248,7 +248,23 @@ async function runStatus() {
|
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
250
|
if (args.includes("--line")) {
|
|
251
|
-
|
|
251
|
+
// Claude Code reicht der Statusline ein JSON per stdin (u. a. session_id).
|
|
252
|
+
// Non-blocking mit kurzem Timeout lesen — bei manuellem Aufruf ohne stdin
|
|
253
|
+
// darf nichts hängen. session_id ergibt den Sitzungs-Recall-Zähler.
|
|
254
|
+
let sessionId = "";
|
|
255
|
+
try {
|
|
256
|
+
const raw = await Promise.race([
|
|
257
|
+
readStdin(),
|
|
258
|
+
new Promise((r) => setTimeout(() => r(""), 80)),
|
|
259
|
+
]);
|
|
260
|
+
if (raw && raw.trim().startsWith("{")) {
|
|
261
|
+
const d = JSON.parse(raw);
|
|
262
|
+
sessionId = d.session_id || d.sessionId || "";
|
|
263
|
+
}
|
|
264
|
+
} catch {
|
|
265
|
+
/* kein/kaputtes stdin — ohne Session weiter */
|
|
266
|
+
}
|
|
267
|
+
process.stdout.write(renderLine(sessionId));
|
|
252
268
|
return;
|
|
253
269
|
}
|
|
254
270
|
console.log(await renderFull());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knowmind",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"mcpName": "io.github.Schubeler-Consulting/knowmind",
|
|
5
5
|
"description": "Knowmind — das Agentengehirn aus Deutschland: CLI + MCP-Server (Langzeitgedächtnis & Wissensgraph für Ihre KI, Server in Deutschland).",
|
|
6
6
|
"type": "module",
|
package/src/init.js
CHANGED
|
@@ -154,7 +154,7 @@ function autoRecallHookSource() {
|
|
|
154
154
|
// npx-Kaltstart; und es gibt KEINE Command-Injection, weil die Nutzer-Frage als
|
|
155
155
|
// JSON-Body und nicht als Shell-Argument übergeben wird. Fail-open: jeder
|
|
156
156
|
// Fehler / fehlendes Token -> exit 0 ohne Ausgabe, blockiert nie.
|
|
157
|
-
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
157
|
+
import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync, unlinkSync } from "node:fs";
|
|
158
158
|
import { homedir } from "node:os";
|
|
159
159
|
import { join } from "node:path";
|
|
160
160
|
|
|
@@ -167,6 +167,30 @@ function markActivity() {
|
|
|
167
167
|
} catch {}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
// Zählt pro Claude-Code-Session die abgerufenen Erinnerungen. Die Statusline
|
|
171
|
+
// zeigt „N abgerufen" für die laufende Sitzung. Best-effort.
|
|
172
|
+
function bumpSessionRecalls(sessionId, hits) {
|
|
173
|
+
if (!sessionId || !(hits > 0)) return;
|
|
174
|
+
try {
|
|
175
|
+
const d = join(homedir(), ".knowmind", "sessions");
|
|
176
|
+
mkdirSync(d, { recursive: true });
|
|
177
|
+
const now = Date.now();
|
|
178
|
+
for (const fn of readdirSync(d)) {
|
|
179
|
+
try {
|
|
180
|
+
if (now - statSync(join(d, fn)).mtimeMs > 86400000) unlinkSync(join(d, fn));
|
|
181
|
+
} catch {}
|
|
182
|
+
}
|
|
183
|
+
const safe = String(sessionId).replace(/[^a-zA-Z0-9_-]/g, "").slice(0, 80);
|
|
184
|
+
const p = join(d, safe + ".json");
|
|
185
|
+
let cur = {};
|
|
186
|
+
try { cur = JSON.parse(readFileSync(p, "utf-8")); } catch {}
|
|
187
|
+
cur.recalls = (cur.recalls || 0) + 1;
|
|
188
|
+
cur.memories = (cur.memories || 0) + hits;
|
|
189
|
+
cur.updated = now;
|
|
190
|
+
writeFileSync(p, JSON.stringify(cur));
|
|
191
|
+
} catch {}
|
|
192
|
+
}
|
|
193
|
+
|
|
170
194
|
const TRIVIAL = new Set([
|
|
171
195
|
"ok","okay","go","ja","nein","weiter","stop","danke","thanks","thx",
|
|
172
196
|
"yes","no","yep","nope","perfekt","passt","super","gut",
|
|
@@ -246,9 +270,11 @@ async function main() {
|
|
|
246
270
|
process.stdin.setEncoding("utf-8");
|
|
247
271
|
for await (const c of process.stdin) raw += c;
|
|
248
272
|
let prompt = "";
|
|
273
|
+
let sessionId = "";
|
|
249
274
|
try {
|
|
250
275
|
const data = raw ? JSON.parse(raw) : {};
|
|
251
276
|
prompt = data.prompt || data.user_prompt || data.user_message || "";
|
|
277
|
+
sessionId = data.session_id || data.sessionId || "";
|
|
252
278
|
} catch { return; }
|
|
253
279
|
if (!shouldRecall(prompt)) return;
|
|
254
280
|
|
|
@@ -279,6 +305,7 @@ async function main() {
|
|
|
279
305
|
|
|
280
306
|
const hits = formatHits(rpc);
|
|
281
307
|
if (!hits) return;
|
|
308
|
+
bumpSessionRecalls(sessionId, (hits.match(/^• /gm) || []).length);
|
|
282
309
|
|
|
283
310
|
process.stdout.write(
|
|
284
311
|
"═════════ knowmind RECALL (auto) ═════════\\n" +
|
|
@@ -505,7 +532,10 @@ function planClaudeCode(cwd) {
|
|
|
505
532
|
// Statusline: knowmind-Lebenszeichen (grüne HDD-LED). NUR setzen, wenn
|
|
506
533
|
// keine existiert oder sie bereits auf knowmind zeigt — eine fremde
|
|
507
534
|
// Statusline des Nutzers wird NIE gekapert.
|
|
508
|
-
|
|
535
|
+
// refreshInterval: Claude Code rendert die Statusline sonst nur bei
|
|
536
|
+
// Ereignissen — damit die grüne LED bei Aktivität sichtbar flackert, muss
|
|
537
|
+
// sie periodisch neu gezeichnet werden (Claude Code >= 2.1.97, Min. 500 ms).
|
|
538
|
+
const km = { type: "command", command: "knowmind status --line", refreshInterval: 500 };
|
|
509
539
|
let m3 = false;
|
|
510
540
|
const existing = settings.statusLine;
|
|
511
541
|
const isKnowmind =
|
|
@@ -513,7 +543,7 @@ function planClaudeCode(cwd) {
|
|
|
513
543
|
if (!existing) {
|
|
514
544
|
settings.statusLine = km;
|
|
515
545
|
m3 = true;
|
|
516
|
-
} else if (isKnowmind && existing.command !== km.command) {
|
|
546
|
+
} else if (isKnowmind && (existing.command !== km.command || existing.refreshInterval !== 500)) {
|
|
517
547
|
settings.statusLine = km;
|
|
518
548
|
m3 = true;
|
|
519
549
|
}
|
package/src/status.js
CHANGED
|
@@ -40,6 +40,15 @@ const brightGreen = (s) => c("92", s);
|
|
|
40
40
|
const dimGreen = (s) => c("2;32", s);
|
|
41
41
|
const red = (s) => c("31", s);
|
|
42
42
|
const dim = (s) => c("2", s);
|
|
43
|
+
const kmBlue = (s) => c("38;5;111", s); // ≈ knowmind-Blau #6ea8ff (Session-Akzent)
|
|
44
|
+
|
|
45
|
+
/** Abgerufene Erinnerungen in DIESER Claude-Code-Session (null wenn keine). */
|
|
46
|
+
function sessionRecalls(sessionId) {
|
|
47
|
+
if (!sessionId) return null;
|
|
48
|
+
const safe = String(sessionId).replace(/[^a-zA-Z0-9_-]/g, "").slice(0, 80);
|
|
49
|
+
const data = readJson(join(KM_DIR, "sessions", safe + ".json"));
|
|
50
|
+
return data && data.memories > 0 ? data.memories : null;
|
|
51
|
+
}
|
|
43
52
|
|
|
44
53
|
/**
|
|
45
54
|
* Grüne Festplatten-LED: bei Aktivität flackert das ●-Zeichen unregelmäßig
|
|
@@ -168,12 +177,14 @@ function hhmm(ts) {
|
|
|
168
177
|
}
|
|
169
178
|
}
|
|
170
179
|
|
|
171
|
-
/** Einzeilige Statusline-Ausgabe.
|
|
172
|
-
|
|
180
|
+
/** Einzeilige Statusline-Ausgabe. Flackert bei Aktivität, erholt sich selbst.
|
|
181
|
+
* sessionId (optional): zeigt „N abgerufen" für die laufende Claude-Code-Sitzung. */
|
|
182
|
+
export function renderLine(sessionId) {
|
|
173
183
|
if (!loadConfig().token && !process.env.KNOWMIND_TOKEN) {
|
|
174
184
|
return dim("○ knowmind · nicht angemeldet");
|
|
175
185
|
}
|
|
176
186
|
const h = healthState();
|
|
187
|
+
const sep = " " + dim("·") + " ";
|
|
177
188
|
|
|
178
189
|
if (h.ok === false) {
|
|
179
190
|
const since = h.downSince ? ` (seit ${hhmm(h.downSince)})` : "";
|
|
@@ -182,13 +193,20 @@ export function renderLine() {
|
|
|
182
193
|
if (h.ok == null) {
|
|
183
194
|
return `${dimGreen("●")} ${dim("knowmind · prüfe …")}`;
|
|
184
195
|
}
|
|
196
|
+
// Session-Zähler = Lebenszeichen dieser Sitzung (knowmind-Blau, auffällig).
|
|
197
|
+
const sess = sessionRecalls(sessionId);
|
|
198
|
+
const sessTxt = sess ? kmBlue(`${fmtCount(sess)} abgerufen`) : null;
|
|
199
|
+
|
|
185
200
|
// erreichbar: bei Aktivität grünes HDD-Flackern, sonst ruhig leuchtend grün
|
|
186
201
|
if (activityAgeMs() <= ACTIVE_MS) {
|
|
187
|
-
return `${flickerLed()} ${dim("knowmind
|
|
202
|
+
return `${flickerLed()} ${dim("knowmind arbeitet")}` + (sessTxt ? sep + sessTxt : "");
|
|
203
|
+
}
|
|
204
|
+
let tail = sessTxt;
|
|
205
|
+
if (!tail) {
|
|
206
|
+
const cnt = readJson(COUNT_CACHE);
|
|
207
|
+
tail = cnt?.count != null ? dim(`${fmtCount(cnt.count)} gespeichert`) : null;
|
|
188
208
|
}
|
|
189
|
-
|
|
190
|
-
const tail = cnt?.count != null ? ` · ${fmtCount(cnt.count)} Erinnerungen` : "";
|
|
191
|
-
return `${green("●")} ${dim("knowmind" + tail)}`;
|
|
209
|
+
return `${green("●")} ${dim("knowmind")}` + (tail ? sep + tail : "");
|
|
192
210
|
}
|
|
193
211
|
|
|
194
212
|
/** Mehrzeilige, menschenlesbare Ausgabe (`knowmind status`). */
|