knowmind 0.1.28 → 0.2.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 +19 -15
- package/README.md +7 -0
- package/bin/knowmind.js +24 -0
- package/package.json +1 -1
- package/src/init.js +32 -3
- package/src/status.js +222 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
# Knowmind CLI — Änderungen
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (2026-07-16)
|
|
4
|
+
|
|
5
|
+
**Neu: `knowmind status` — sichtbares Lebenszeichen des Gedächtnisses**
|
|
6
|
+
- `knowmind status` zeigt einen kurzen Erreichbarkeits-Report (erreichbar,
|
|
7
|
+
Anzahl Erinnerungen und Beziehungen, Antwortzeit).
|
|
8
|
+
- `knowmind status --line` gibt eine einzeilige Statusline für Ihr KI-Werkzeug
|
|
9
|
+
aus: ruhig grün, wenn erreichbar; grünes Flackern wie eine Festplatten-LED,
|
|
10
|
+
während knowmind arbeitet; rot bei Ausfall (mit Selbst-Erholung). Die Anzeige
|
|
11
|
+
blockiert nie — Erreichbarkeit und Zahl werden gecacht, im Hintergrund
|
|
12
|
+
aufgefrischt.
|
|
13
|
+
- `knowmind init --client claude-code` bindet die Statusline automatisch ein.
|
|
14
|
+
Eine bereits vorhandene eigene Statusline bleibt unangetastet.
|
|
15
|
+
|
|
16
|
+
## 0.1.29 (2026-07-16)
|
|
17
|
+
|
|
18
|
+
- Verbesserungen der Stabilität und allgemeine Fehlerbehebungen.
|
|
19
|
+
|
|
3
20
|
## 0.1.28 (2026-07-16)
|
|
4
21
|
|
|
5
|
-
|
|
6
|
-
- Server-Versionen vom 16.07. stellten dem Recall-JSON zeitweise einen
|
|
7
|
-
Präsenz-Marker voran; `knowmind search` stürzte mit „Unexpected token ●"
|
|
8
|
-
ab. Der Client parst Tool-Antworten jetzt tolerant (ab der ersten
|
|
9
|
-
öffnenden Klammer). Serverseitig wurde der Marker ebenfalls entfernt.
|
|
22
|
+
- Verbesserungen der Stabilität und allgemeine Fehlerbehebungen.
|
|
10
23
|
|
|
11
24
|
## 0.1.27 (2026-07-16)
|
|
12
25
|
|
|
13
|
-
|
|
14
|
-
- Der NTFS-Lockdown vergab Datei-Rechte mit Vererbungsflags `(OI)(CI)` — auf
|
|
15
|
-
Dateien sind solche ACEs wirkungslos (Inherit-Only). Ergebnis: direkt nach
|
|
16
|
-
erfolgreichem `knowmind login` war die Config für alle Konten gesperrt und
|
|
17
|
-
jeder Folgebefehl endete mit „Kein Token konfiguriert", obwohl icacls Exit 0
|
|
18
|
-
meldete. Jetzt bekommen Dateien `:F` ohne Vererbungsflags, Ordner weiterhin
|
|
19
|
-
`:(OI)(CI)F`. Gefunden im E2E-Kundendurchlauf auf Windows 11 (Deutsch).
|
|
20
|
-
- Betroffen: jede Neuanmeldung unter Windows seit Einführung des Lockdowns.
|
|
21
|
-
Abhilfe für Betroffene: einmal `knowmind login --token …` mit 0.1.27
|
|
22
|
-
wiederholen (überschreibt die Config mit korrekten Rechten).
|
|
26
|
+
- Verbesserungen der Stabilität und allgemeine Fehlerbehebungen.
|
|
23
27
|
|
|
24
28
|
## 0.1.25 (2026-06-23)
|
|
25
29
|
|
package/README.md
CHANGED
|
@@ -40,9 +40,16 @@ knowmind search "Wo läuft die OKR-App?"
|
|
|
40
40
|
knowmind upload notizen.md --title "Meeting Notizen 2026-05-12"
|
|
41
41
|
knowmind stats
|
|
42
42
|
knowmind health
|
|
43
|
+
knowmind status Lebenszeichen des Gedächtnisses (Report)
|
|
44
|
+
knowmind status --line Einzeilige Statusline für Ihr KI-Werkzeug
|
|
43
45
|
knowmind config
|
|
44
46
|
```
|
|
45
47
|
|
|
48
|
+
Die Statusline (`knowmind status --line`) zeigt knowmind als grüne Lampe direkt in Ihrem
|
|
49
|
+
KI-Werkzeug: ruhig grün, wenn erreichbar, grünes Flackern wie eine Festplatten-LED, während
|
|
50
|
+
knowmind arbeitet, rot bei Ausfall. `knowmind init --client claude-code` bindet sie
|
|
51
|
+
automatisch ein (eine bereits vorhandene eigene Statusline bleibt unangetastet).
|
|
52
|
+
|
|
46
53
|
## Automatische Pflege einrichten (`knowmind init`)
|
|
47
54
|
|
|
48
55
|
Damit Ihre KI knowmind selbsttätig pflegt — **Recall vor jeder Aufgabe**, **Sichern nach
|
package/bin/knowmind.js
CHANGED
|
@@ -25,6 +25,7 @@ import { runStdioServer } from "../src/mcp-stdio.js";
|
|
|
25
25
|
import { syncDirectory } from "../src/sync.js";
|
|
26
26
|
import { runInit } from "../src/init.js";
|
|
27
27
|
import { runInstall } from "../src/install.js";
|
|
28
|
+
import { renderLine, renderFull, probe } from "../src/status.js";
|
|
28
29
|
|
|
29
30
|
const args = process.argv.slice(2);
|
|
30
31
|
const cmd = args[0];
|
|
@@ -65,6 +66,11 @@ Befehle:
|
|
|
65
66
|
Content-Hash, Manifest in <dir>/.knowmind-manifest.json.
|
|
66
67
|
knowmind stats Memory- und Edge-Counter des Tenants
|
|
67
68
|
knowmind health Health-Check der Plattform
|
|
69
|
+
knowmind status [--line]
|
|
70
|
+
Lebenszeichen des Gedächtnisses. Ohne Flag: Report.
|
|
71
|
+
--line: einzeilige Statusline (grüne HDD-LED, flackert
|
|
72
|
+
bei Aktivität, rot bei Ausfall) — für die Statusline
|
|
73
|
+
eines KI-Werkzeugs, z. B. Claude Code.
|
|
68
74
|
knowmind mcp Stdio-MCP-Server für lokale AI-Clients
|
|
69
75
|
knowmind install <ide> [--project] [--print] [--token T] [--api URL]
|
|
70
76
|
knowmind als MCP-Server in eine IDE eintragen
|
|
@@ -233,6 +239,21 @@ async function runConfig() {
|
|
|
233
239
|
console.log(`Token: ${c.token ? c.token.slice(0, 12) + "…" : "(keiner)"}`);
|
|
234
240
|
}
|
|
235
241
|
|
|
242
|
+
async function runStatus() {
|
|
243
|
+
// --probe: interner Hintergrund-Refresh der Status-Caches (nicht blockierend
|
|
244
|
+
// für die Statusline). --line: einzeilige, gefärbte Ausgabe für die Statusline
|
|
245
|
+
// eines KI-Werkzeugs. Ohne Flag: menschenlesbarer Mehrzeilen-Report.
|
|
246
|
+
if (args.includes("--probe")) {
|
|
247
|
+
await probe();
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (args.includes("--line")) {
|
|
251
|
+
process.stdout.write(renderLine());
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
console.log(await renderFull());
|
|
255
|
+
}
|
|
256
|
+
|
|
236
257
|
async function runInitCmd() {
|
|
237
258
|
const client = parseFlag("--client", "auto");
|
|
238
259
|
const dryRun = args.includes("--dry-run");
|
|
@@ -294,6 +315,9 @@ try {
|
|
|
294
315
|
case "health":
|
|
295
316
|
await runHealth();
|
|
296
317
|
break;
|
|
318
|
+
case "status":
|
|
319
|
+
await runStatus();
|
|
320
|
+
break;
|
|
297
321
|
case "mcp":
|
|
298
322
|
await runStdioServer();
|
|
299
323
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knowmind",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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,10 +154,19 @@ 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 } from "node:fs";
|
|
157
|
+
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
158
158
|
import { homedir } from "node:os";
|
|
159
159
|
import { join } from "node:path";
|
|
160
160
|
|
|
161
|
+
// Stempelt den Aktivitäts-Zeitpunkt für die knowmind-Statusline (grüne
|
|
162
|
+
// HDD-LED). Best-effort, darf den Recall nie brechen.
|
|
163
|
+
function markActivity() {
|
|
164
|
+
try {
|
|
165
|
+
mkdirSync(join(homedir(), ".knowmind"), { recursive: true });
|
|
166
|
+
writeFileSync(join(homedir(), ".knowmind", "activity"), String(Date.now()));
|
|
167
|
+
} catch {}
|
|
168
|
+
}
|
|
169
|
+
|
|
161
170
|
const TRIVIAL = new Set([
|
|
162
171
|
"ok","okay","go","ja","nein","weiter","stop","danke","thanks","thx",
|
|
163
172
|
"yes","no","yep","nope","perfekt","passt","super","gut",
|
|
@@ -245,6 +254,7 @@ async function main() {
|
|
|
245
254
|
|
|
246
255
|
const { apiUrl, token } = loadCreds();
|
|
247
256
|
if (!token) return;
|
|
257
|
+
markActivity();
|
|
248
258
|
const query = prompt.trim().slice(0, 500);
|
|
249
259
|
|
|
250
260
|
const ctrl = new AbortController();
|
|
@@ -492,11 +502,30 @@ function planClaudeCode(cwd) {
|
|
|
492
502
|
const relCapture = ".claude/hooks/knowmind_capture.mjs";
|
|
493
503
|
const m1 = ensureClaudeHookEntry(settings, "UserPromptSubmit", relRecall);
|
|
494
504
|
const m2 = ensureClaudeHookEntry(settings, "Stop", relCapture);
|
|
505
|
+
// Statusline: knowmind-Lebenszeichen (grüne HDD-LED). NUR setzen, wenn
|
|
506
|
+
// keine existiert oder sie bereits auf knowmind zeigt — eine fremde
|
|
507
|
+
// Statusline des Nutzers wird NIE gekapert.
|
|
508
|
+
const km = { type: "command", command: "knowmind status --line" };
|
|
509
|
+
let m3 = false;
|
|
510
|
+
const existing = settings.statusLine;
|
|
511
|
+
const isKnowmind =
|
|
512
|
+
existing && typeof existing.command === "string" && existing.command.includes("knowmind status");
|
|
513
|
+
if (!existing) {
|
|
514
|
+
settings.statusLine = km;
|
|
515
|
+
m3 = true;
|
|
516
|
+
} else if (isKnowmind && existing.command !== km.command) {
|
|
517
|
+
settings.statusLine = km;
|
|
518
|
+
m3 = true;
|
|
519
|
+
}
|
|
495
520
|
actions.push({
|
|
496
|
-
label: "Claude-Code settings.json (
|
|
521
|
+
label: "Claude-Code settings.json (Hooks + Statusline)",
|
|
497
522
|
path: settingsPath,
|
|
498
|
-
action: m1 || m2 ? (existsSync(settingsPath) ? "patch" : "create") : "unchanged",
|
|
523
|
+
action: m1 || m2 || m3 ? (existsSync(settingsPath) ? "patch" : "create") : "unchanged",
|
|
499
524
|
content: JSON.stringify(settings, null, 2) + "\n",
|
|
525
|
+
_note:
|
|
526
|
+
existing && !isKnowmind
|
|
527
|
+
? "Eigene Statusline erkannt — nicht überschrieben. Manuell einbinden: knowmind status --line"
|
|
528
|
+
: undefined,
|
|
500
529
|
});
|
|
501
530
|
}
|
|
502
531
|
|
package/src/status.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowmind status — sichtbares Lebenszeichen des Gedächtnisses.
|
|
3
|
+
*
|
|
4
|
+
* Zwei Ausgaben:
|
|
5
|
+
* renderFull() → mehrzeilig, menschenlesbar (`knowmind status`)
|
|
6
|
+
* renderLine() → einzeilig, gefärbt, für die Statusline eines KI-Werkzeugs
|
|
7
|
+
* (`knowmind status --line`, z. B. Claude-Code statusLine)
|
|
8
|
+
*
|
|
9
|
+
* Die Statusline wird oft gerendert und darf NIE blockieren. Deshalb:
|
|
10
|
+
* - Erreichbarkeit + Erinnerungszahl liegen in Cache-Dateien unter ~/.knowmind.
|
|
11
|
+
* - Ist der Cache abgelaufen, wird ein LOSGELÖSTER Hintergrund-Probe gestartet
|
|
12
|
+
* (`knowmind status --probe`), der den Cache auffrischt (stale-while-revalidate).
|
|
13
|
+
* - Läuft knowmind gerade (Recall in den letzten Sekunden — der init-Recall-Hook
|
|
14
|
+
* stempelt ~/.knowmind/activity), blinkt die Anzeige.
|
|
15
|
+
*/
|
|
16
|
+
import { spawn } from "node:child_process";
|
|
17
|
+
import { existsSync, readFileSync, writeFileSync, statSync, mkdirSync } from "node:fs";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import { join, dirname } from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import { loadConfig } from "./config.js";
|
|
22
|
+
import { health, stats } from "./client.js";
|
|
23
|
+
|
|
24
|
+
const KM_DIR = join(homedir(), ".knowmind");
|
|
25
|
+
const HEALTH_CACHE = join(KM_DIR, "status-health.json");
|
|
26
|
+
const COUNT_CACHE = join(KM_DIR, "status-count.json");
|
|
27
|
+
const ACTIVITY = join(KM_DIR, "activity");
|
|
28
|
+
|
|
29
|
+
const HEALTH_TTL_OK = 30_000; // erreichbar → alle 30 s neu prüfen
|
|
30
|
+
const HEALTH_TTL_FAIL = 15_000; // gestört → alle 15 s (schnellere Erholung)
|
|
31
|
+
const PROBE_GUARD = 12_000; // kein zweiter Hintergrund-Probe innerhalb 12 s
|
|
32
|
+
const COUNT_TTL = 900_000; // Erinnerungszahl: 15 min
|
|
33
|
+
const ACTIVE_MS = 15_000; // Recall jünger als 15 s → „arbeitet"
|
|
34
|
+
|
|
35
|
+
// ANSI (dezent). NO_COLOR respektieren.
|
|
36
|
+
const useColor = !process.env.NO_COLOR;
|
|
37
|
+
const c = (code, s) => (useColor ? `[${code}m${s}[0m` : s);
|
|
38
|
+
const green = (s) => c("32", s);
|
|
39
|
+
const brightGreen = (s) => c("92", s);
|
|
40
|
+
const dimGreen = (s) => c("2;32", s);
|
|
41
|
+
const red = (s) => c("31", s);
|
|
42
|
+
const dim = (s) => c("2", s);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Grüne Festplatten-LED: bei Aktivität flackert das ●-Zeichen unregelmäßig
|
|
46
|
+
* zwischen hell- und dunkelgrün (nicht im gleichmäßigen Takt). Die Statusline
|
|
47
|
+
* wird bei Arbeit häufig neu gerendert — das bit-gemischte Zeit-Muster erzeugt
|
|
48
|
+
* dabei das nervöse HDD-Flackern statt eines sauberen Blinkens.
|
|
49
|
+
*/
|
|
50
|
+
function flickerLed() {
|
|
51
|
+
const t = Date.now();
|
|
52
|
+
const on = (((t >> 6) ^ (t >> 4) ^ (t >> 8)) & 1) === 1;
|
|
53
|
+
return on ? brightGreen("●") : dimGreen("●");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readJson(path) {
|
|
57
|
+
try {
|
|
58
|
+
return JSON.parse(readFileSync(path, "utf-8"));
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function writeJson(path, obj) {
|
|
65
|
+
try {
|
|
66
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
67
|
+
writeFileSync(path, JSON.stringify(obj), "utf-8");
|
|
68
|
+
} catch {
|
|
69
|
+
/* best effort */
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function fmtCount(n) {
|
|
74
|
+
return String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Sekunden-genaue mtime von ~/.knowmind/activity (0 wenn nicht vorhanden). */
|
|
78
|
+
function activityAgeMs() {
|
|
79
|
+
try {
|
|
80
|
+
return Date.now() - statSync(ACTIVITY).mtimeMs;
|
|
81
|
+
} catch {
|
|
82
|
+
return Infinity;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Stempelt den Aktivitäts-Zeitpunkt. Wird vom Recall-Hook aufgerufen. */
|
|
87
|
+
export function markActivity() {
|
|
88
|
+
try {
|
|
89
|
+
mkdirSync(KM_DIR, { recursive: true });
|
|
90
|
+
writeFileSync(ACTIVITY, String(Date.now()), "utf-8");
|
|
91
|
+
} catch {
|
|
92
|
+
/* best effort */
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Interner Probe-Modus: Health + Zahl frisch holen, Cache schreiben. */
|
|
97
|
+
export async function probe() {
|
|
98
|
+
const t0 = Date.now();
|
|
99
|
+
try {
|
|
100
|
+
const h = await health();
|
|
101
|
+
const ok = String(h?.status ?? "").toLowerCase() === "ok";
|
|
102
|
+
const prev = readJson(HEALTH_CACHE) || {};
|
|
103
|
+
writeJson(HEALTH_CACHE, {
|
|
104
|
+
ts: Date.now(),
|
|
105
|
+
ok,
|
|
106
|
+
latencyMs: Date.now() - t0,
|
|
107
|
+
downSince: ok ? null : prev.downSince || Date.now(),
|
|
108
|
+
probing: 0,
|
|
109
|
+
});
|
|
110
|
+
if (ok) {
|
|
111
|
+
try {
|
|
112
|
+
const s = await stats();
|
|
113
|
+
const n = s?.memories ?? s?.memory_count ?? s?.count ?? null;
|
|
114
|
+
if (n != null) writeJson(COUNT_CACHE, { ts: Date.now(), count: Number(n) });
|
|
115
|
+
} catch {
|
|
116
|
+
/* Zahl ist optional */
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
const prev = readJson(HEALTH_CACHE) || {};
|
|
121
|
+
writeJson(HEALTH_CACHE, {
|
|
122
|
+
ts: Date.now(),
|
|
123
|
+
ok: false,
|
|
124
|
+
latencyMs: 0,
|
|
125
|
+
downSince: prev.downSince || Date.now(),
|
|
126
|
+
probing: 0,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Losgelösten Hintergrund-Probe starten (blockiert die Statusline nie). */
|
|
132
|
+
function spawnProbe() {
|
|
133
|
+
try {
|
|
134
|
+
const self = fileURLToPath(new URL("../bin/knowmind.js", import.meta.url));
|
|
135
|
+
const child = spawn(process.execPath, [self, "status", "--probe"], {
|
|
136
|
+
detached: true,
|
|
137
|
+
stdio: "ignore",
|
|
138
|
+
});
|
|
139
|
+
child.unref();
|
|
140
|
+
} catch {
|
|
141
|
+
/* best effort */
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Erreichbarkeits-Zustand aus Cache; stößt bei Ablauf einen Refresh an. */
|
|
146
|
+
function healthState() {
|
|
147
|
+
const cache = readJson(HEALTH_CACHE);
|
|
148
|
+
const now = Date.now();
|
|
149
|
+
if (!cache) {
|
|
150
|
+
// Allererster Aufruf: einmal im Hintergrund prüfen, vorerst „unbekannt".
|
|
151
|
+
spawnProbe();
|
|
152
|
+
return { ok: null, ts: 0 };
|
|
153
|
+
}
|
|
154
|
+
const ttl = cache.ok ? HEALTH_TTL_OK : HEALTH_TTL_FAIL;
|
|
155
|
+
if (now - (cache.ts || 0) > ttl && now - (cache.probing || 0) > PROBE_GUARD) {
|
|
156
|
+
cache.probing = now;
|
|
157
|
+
writeJson(HEALTH_CACHE, cache);
|
|
158
|
+
spawnProbe();
|
|
159
|
+
}
|
|
160
|
+
return cache;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function hhmm(ts) {
|
|
164
|
+
try {
|
|
165
|
+
return new Date(ts).toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit" });
|
|
166
|
+
} catch {
|
|
167
|
+
return "?";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Einzeilige Statusline-Ausgabe. Blinkt bei Aktivität, erholt sich selbst. */
|
|
172
|
+
export function renderLine() {
|
|
173
|
+
if (!loadConfig().token && !process.env.KNOWMIND_TOKEN) {
|
|
174
|
+
return dim("○ knowmind · nicht angemeldet");
|
|
175
|
+
}
|
|
176
|
+
const h = healthState();
|
|
177
|
+
|
|
178
|
+
if (h.ok === false) {
|
|
179
|
+
const since = h.downSince ? ` (seit ${hhmm(h.downSince)})` : "";
|
|
180
|
+
return `${red("●")} ${dim(`knowmind · nicht erreichbar${since}`)}`;
|
|
181
|
+
}
|
|
182
|
+
if (h.ok == null) {
|
|
183
|
+
return `${dimGreen("●")} ${dim("knowmind · prüfe …")}`;
|
|
184
|
+
}
|
|
185
|
+
// erreichbar: bei Aktivität grünes HDD-Flackern, sonst ruhig leuchtend grün
|
|
186
|
+
if (activityAgeMs() <= ACTIVE_MS) {
|
|
187
|
+
return `${flickerLed()} ${dim("knowmind · arbeitet")}`;
|
|
188
|
+
}
|
|
189
|
+
const cnt = readJson(COUNT_CACHE);
|
|
190
|
+
const tail = cnt?.count != null ? ` · ${fmtCount(cnt.count)} Erinnerungen` : "";
|
|
191
|
+
return `${green("●")} ${dim("knowmind" + tail)}`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Mehrzeilige, menschenlesbare Ausgabe (`knowmind status`). */
|
|
195
|
+
export async function renderFull() {
|
|
196
|
+
if (!loadConfig().token && !process.env.KNOWMIND_TOKEN) {
|
|
197
|
+
return "knowmind: nicht angemeldet — `knowmind login --token kmt_…` ausführen.";
|
|
198
|
+
}
|
|
199
|
+
const t0 = Date.now();
|
|
200
|
+
try {
|
|
201
|
+
const h = await health();
|
|
202
|
+
const ok = String(h?.status ?? "").toLowerCase() === "ok";
|
|
203
|
+
const ms = Date.now() - t0;
|
|
204
|
+
if (!ok) return red("● knowmind nicht erreichbar.");
|
|
205
|
+
let line = green("● knowmind erreichbar") + dim(` · ${ms} ms`);
|
|
206
|
+
try {
|
|
207
|
+
const s = await stats();
|
|
208
|
+
const n = s?.memories ?? s?.memory_count ?? s?.count;
|
|
209
|
+
const e = s?.edges;
|
|
210
|
+
if (n != null) line += `\n Erinnerungen: ${fmtCount(Number(n))}`;
|
|
211
|
+
if (e != null) line += `\n Beziehungen: ${fmtCount(Number(e))}`;
|
|
212
|
+
if (s?.memoryLimit != null) line += dim(`\n Tarif-Limit: ${fmtCount(Number(s.memoryLimit))}`);
|
|
213
|
+
} catch {
|
|
214
|
+
/* Zahl optional */
|
|
215
|
+
}
|
|
216
|
+
// Cache gleich mitschreiben, damit die Statusline sofort frisch ist.
|
|
217
|
+
await probe();
|
|
218
|
+
return line;
|
|
219
|
+
} catch (e) {
|
|
220
|
+
return red(`● knowmind nicht erreichbar: ${e.message}`);
|
|
221
|
+
}
|
|
222
|
+
}
|