repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

Merge remote-tracking branch 'bugabinga/trunk' into audio-event-driven-state

919a52b4dcb106dfe874456c73a0b0685b5c82fc

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

# Conflicts:
#	pi-ext
#	pi/agent/settings.json

Changed files (8)

NB-00718.symlinks

Modified
1 1 forgejo-cli
2 2 ~/AppData/Roaming/Cyborus/forgejo-cli/config
4 +claude/settings.json
5 +~/.claude/settings.json
7 +claude/cc-statusline-hook.js
8 +~/.claude/cc-statusline-hook.js
10 +claude/statusline.js
11 +~/.claude/statusline.js
13 +claude/CLAUDE.md
14 +~/.claude/CLAUDE.md
16 +claude/RTK.md
17 +~/.claude/RTK.md
19 +codex/config.toml
20 +~/.codex/config.toml
4 22 Notes
5 23 ~/Notes

claude/STATUSLINE.md

Added
new file mode 100644
1 +# Claude Code Statusline
3 +Eine einzeilige, Statusline für Claude Code.
4 +Reines Node (stdlib), ein Renderer + ein Hook. Cross-Plattform (win/mac/linux).
6 +Beispielausgabe:
8 +```
9 + RD-1950 · Opus 4.8 · xhigh · RD-1950 · 5h ██▋░░░░░ 33%·2h44m · 7d █▏░░░░░░ 14% · 🔥$26.68/hr · $0.499 $136.54Σ $486.13☾ · caveman:full
10 +```
12 +Segmente (v.l.n.r.): Verzeichnis · Modell · Effort · Git/JJ-Branch · 5h-Limit ·
13 +7d-Limit · Burn-Rate ($/h) · Kosten (Turn / Session Σ / Monat ☾) · Caveman-Badge.
15 +---
17 +## Voraussetzungen
19 +| Dep | Pflicht | Zweck |
20 +|-----|---------|-------|
21 +| **Node ≥ 18** | ✅ | Laufzeit. Nur stdlib (`fs/os/path/crypto/child_process`), keine npm-Pakete. |
22 +| **Claude Code** | ✅ | Liefert den JSON-Payload (inkl. Kosten) via stdin. |
23 +| **git** oder **jj** | ➖ | Branch-Segment. Muss im `PATH` sein. Ohne → Segment entfällt. |
24 +| **Nerd Font** | ➖ (empfohlen) | Glyphen ``, Balken `█▏░`, Icons. Ohne → Tofu (`□`). |
25 +| **caveman-Plugin** | ➖ | Caveman-Badge. Ohne → Badge entfällt. |
27 +---
29 +## Dateien
31 +| Datei | Rolle |
32 +|-------|-------|
33 +| [`statusline.js`](./statusline.js) | Renderer. Liest stdin-JSON, gibt eine Zeile aus. |
34 +| [`cc-statusline-hook.js`](./cc-statusline-hook.js) | Hook. Setzt Turn-Marker + Workflow-Badge. |
36 +Beide nach `~/.claude/` kopieren oder symlinken:
38 +```bash
39 +ln -s "$PWD/statusline.js" ~/.claude/statusline.js
40 +ln -s "$PWD/cc-statusline-hook.js" ~/.claude/cc-statusline-hook.js
41 +```
43 +---
45 +## Installation
47 +1. Node ≥ 18 installieren, im `PATH`.
48 +2. Beide Dateien nach `~/.claude/` (s.o.).
49 +3. `~/.claude/settings.json` ergänzen (Auszug unten).
50 +4. Nerd Font im Terminal aktivieren (sonst Tofu statt Glyphen).
51 +5. Claude Code neu starten.
53 +### settings.json (Auszug)
55 +```jsonc
57 + "statusLine": {
58 + "type": "command",
59 + "command": "node ~/.claude/statusline.js"
60 + },
61 + "hooks": {
62 + // Turn-Marker: Basis für die "Turn"-Kosten (Δ seit letztem Prompt)
63 + "UserPromptSubmit": [
64 + {
65 + "hooks": [
66 + { "type": "command", "command": "node ~/.claude/cc-statusline-hook.js" }
67 + ]
68 + }
69 + ],
70 + // Workflow-Badge: NUR beim Workflow-Tool feuern (matcher scoped!)
71 + "PreToolUse": [
72 + {
73 + "matcher": "Workflow",
74 + "hooks": [
75 + { "type": "command", "command": "node ~/.claude/cc-statusline-hook.js" }
76 + ]
77 + }
78 + ]
79 + }
81 +```
83 +Der Hook ist **ein** Skript für beide Events; es verzweigt über `hook_event_name`.
85 +---
87 +## Funktionsweise
89 +- Claude Code spawnt `statusline.js` **pro Render** (frischer Prozess, Payload via
90 + stdin, 300 ms Debounce, event-getriggert: neue Assistant-Nachricht, `/compact`,
91 + Permission-/Vim-Mode-Wechsel). Per-Render-Spawn ist von der API erzwungen.
92 +- Renderer baut Segmente, jeweils eigener `try/catch` (ein Crash darf die Zeile nicht
93 + leeren), und schreibt **ohne** Trailing-Newline.
94 +- **Turn-Kosten**: Der Hook legt bei `UserPromptSubmit` eine Marker-Datei
95 + `~/.claude/.cc-turn-<session>` an. Der nächste Render liest sie, rebaselined den
96 + Turn-Start und löscht den Marker.
97 +- **Workflow-Badge**: Bei `PreToolUse(Workflow)` schreibt der Hook eine selbst-
98 + ablaufende Zeile nach `~/.claude/.cc-statusline-extra` (TTL 120 s), die der Renderer
99 + rendert.
100 +- **Kosten-Ledger** `~/.claude/.cc-cost-ledger.json`: Turn / Session / Monat (monats-
101 + übergreifend kumuliert). Idle-Renders (keine Kostenänderung) schreiben nicht.
102 + Selbst-GC räumt alte `.cc-*.tmp` / `.cc-turn-*` (> 1 Tag) auf.
104 +---
106 +## Anpassung
108 +Tunables stehen oben in `statusline.js` im `CONFIG`-Block:
110 +| Schlüssel | Default | Bedeutung |
111 +|-----------|---------|-----------|
112 +| `sep` | `" · "` | Trenner zwischen Segmenten. |
113 +| `barWidth` | `8` | Zellen pro Usage-Balken. |
114 +| `costStyle` | `"icon"` | `"icon"` = helle `$Zahl` + gedämpftes Glyph; `"slash"` = `$x/turn`. |
115 +| `gitCacheTtlMs` | `8000` | Cache für `git status` (Spawn ist ~400 ms kalt auf win32). |
116 +| `contextWarnPct`/`CritPct` | `70`/`90` | Schwellen Kontext-Balken (gelb/rot). |
117 +| `usageWarnPct`/`CritPct` | `50`/`80` | Schwellen Rate-Limit-Balken. |
118 +| `burnWindowMs` | `10 min` | Fenster für die Burn-Rate ($/h). |
120 +---
122 +## Performance (win32)
124 +- Harte Untergrenze ist **nicht** das Skript, sondern der Node-Kaltstart:
125 + `node -e 0` ≈ **120 ms** (Prozess-Spawn + V8-Init). Nicht durch Flags reduzierbar.
126 +- **< 100 ms ist mit Node unmöglich.** Nur ein kompiliertes Binary (Go/Rust ~10–20 ms)
127 + unterbietet das — kostet aber Cross-Plattform (per-OS-Builds) + zweite Codebase.
128 + Bun (win32) und Deno sind langsamer als Node; LLRT kann kein stdin lesen. → Node.
129 +- Die Bar ist asynchron und blockiert keine Eingabe; ~120–140 ms sind unsichtbar.
131 +---
133 +## Troubleshooting
135 +| Symptom | Ursache / Fix |
136 +|---------|---------------|
137 +| `□`/Tofu statt Glyphen | Nerd Font nicht aktiv im Terminal. |
138 +| Keine Kosten | Alte Claude-Code-Version ohne `cost` im Payload. |
139 +| Kein Branch-Segment | `git`/`jj` nicht im `PATH`, oder nicht in einem Repo. |
140 +| Keine Turn-Kosten | Hook nicht in `UserPromptSubmit` registriert. |
141 +| Statusline leer | `statusline.js` wirft beim Start — manuell testen: `echo '{}' \| node ~/.claude/statusline.js`. |

claude/statusline.js

Modified
21 21 // ─── CONFIG ──────────────────────────────────────────────────────────────────
22 22 const CONFIG = {
23 - sep: " · ", // segment padding
23 + sep: " · ", // segment padding (single-space around the dot — tight)
24 24 barWidth: 8, // usage bar cells
25 25 contextWarnPct: 70,
26 26 contextCritPct: 90,
27 27 usageAlways: true,
28 28 usageWarnPct: 50,
29 29 usageCritPct: 80,
30 - costStyle: "icon", // "slash" → $0.15/turn | "icon" → ⟳$0.15
31 - gitCacheTtlMs: 3000,
30 + costStyle: "icon", // "slash" → $0.15/turn | "icon" → bright $0.15 + dim trailing glyph
31 + gitCacheTtlMs: 8000, // git status spawn is ~400ms cold on win32 — cache harder
32 32 extraTtlMs: 120000,
33 33 cmdTimeoutMs: 2500,
34 34 ledgerPruneDays: 40,
97 97 // ─── 2. model ──────────────────────────────────────────────────────────────────
98 98 try {
99 - if (d?.model?.display_name) push(c.magenta(d.model.display_name));
99 + // strip the " (1M context)" / any trailing parenthetical — keep just "Opus 4.8"
100 + if (d?.model?.display_name) push(c.magenta(d.model.display_name.replace(/\s*\([^)]*\)\s*$/, "")));
100 101 } catch {}
102 103 // ─── 3. effort / thinking ──────────────────────────────────────────────────────
105 106 if (lvl) {
106 107 const on = d?.thinking?.enabled !== false;
107 108 const col = lvl === "max" || lvl === "xhigh" ? c.magenta : lvl === "high" ? c.blue : c.dim;
108 - push(on ? col(`⚡${lvl}`) : c.dim(`⚡${lvl}`));
109 + push(on ? col(lvl) : c.dim(lvl)); // no ⚡ glyph — level word alone
110 111 } catch {}
159 160 const { turn, month, burnRate } = updateLedger(sid, total);
160 161 // 🔥 burn rate: own segment, before the cost cluster (matches bars · 🔥 · cost)
161 162 if (burnRate > 0) push(c.orange(`🔥$${burnRate.toFixed(2)}/hr`));
162 - // icon: semantic glyph (⟳ turn / Σ session / ☾ month). slash: <num>/<type>.
163 - const fmt = (n, type, icon, color) =>
164 - CONFIG.costStyle === "icon" ? color(`${icon}$${money(n)}`) : color(`$${money(n)}/${type}`);
163 + // icon style: bright $number (emphasis) + dim trailing glyph (muted icon).
164 + // turn has no glyph (bare $num); session Σ / month ☾. slash: $num/type.
165 + const fmt = (n, type, icon) =>
166 + CONFIG.costStyle === "icon"
167 + ? c.white(`$${money(n)}`) + (icon ? c.dim(icon) : "")
168 + : c.white(`$${money(n)}/${type}`);
165 169 const seg = [];
166 - if (turn > 0) seg.push(fmt(turn, "turn", "⟳", c.white));
167 - seg.push(fmt(total, "session", "Σ", c.dim));
168 - if (month > 0) seg.push(fmt(month, "month", "☾", c.dim));
170 + if (turn > 0) seg.push(fmt(turn, "turn", ""));
171 + seg.push(fmt(total, "session", "Σ"));
172 + if (month > 0) seg.push(fmt(month, "month", "☾"));
169 173 push(seg.join(" "));
171 175 } catch {}
210 214 L = JSON.parse(fs.readFileSync(file, "utf8"));
211 215 } catch {}
212 216 if (!L.sessions) L.sessions = {};
217 + let dirty = false; // persist (disk write) only when something material changed
214 219 // New month → reset the bucket, KEEP per-session baselines so a session that
215 220 // straddles midnight only contributes its post-boundary spend.
216 221 if (L.month !== mk) {
217 222 L.month = mk;
218 223 L.monthTotal = 0;
224 + dirty = true;
221 227 // Prune stale sessions.
233 239 if (fs.existsSync(marker)) {
234 240 s.turnStart = total;
235 241 fs.unlinkSync(marker);
242 + dirty = true;
237 244 } catch {}
239 246 // Month bucket gets only the new spend since this session was last seen.
240 247 const delta = total - (s.total ?? 0);
241 - if (delta > 0) L.monthTotal = (L.monthTotal || 0) + delta;
248 + if (delta > 0) {
249 + L.monthTotal = (L.monthTotal || 0) + delta;
250 + dirty = true;
243 253 const turn = Math.max(0, total - (s.turnStart ?? total));
244 - s.total = total;
245 - s.ts = now;
247 - // Timestamped cost samples for the burn rate. Append, drop anything older than
248 - // the window (so idle time falls off instead of dragging the rate down), cap.
255 + // Burn-rate samples: only record a new (ts,total) when spend actually moved.
256 + // Idle re-renders carry no new info and would force a needless disk write.
249 257 if (!Array.isArray(s.samples)) s.samples = [];
250 - s.samples.push([now, total]);
258 + if (delta > 0) {
259 + s.total = total;
260 + s.ts = now;
261 + s.samples.push([now, total]);
262 + if (s.samples.length > CONFIG.burnMaxSamples) s.samples = s.samples.slice(-CONFIG.burnMaxSamples);
264 + // Prune the window in-memory every render (cheap, no disk) so even an idle
265 + // render shows a current-window rate rather than a stale one.
251 266 const wcut = now - CONFIG.burnWindowMs;
252 267 s.samples = s.samples.filter((p) => p[0] >= wcut);
253 - if (s.samples.length > CONFIG.burnMaxSamples) s.samples = s.samples.slice(-CONFIG.burnMaxSamples);
254 268 const burnRate = computeBurnRate(s.samples);
256 270 L.sessions[sid] = s;
258 - try {
259 - const tmp = `${file}.${process.pid}.tmp`;
260 - fs.writeFileSync(tmp, JSON.stringify(L));
261 - fs.renameSync(tmp, file);
262 - } catch {}
272 + // Persist only when something changed — skips stringify+write+rename (the bulk
273 + // of this function's cost) on the common idle re-render path.
274 + if (dirty) {
275 + try {
276 + const tmp = `${file}.${process.pid}.tmp`;
277 + fs.writeFileSync(tmp, JSON.stringify(L));
278 + fs.renameSync(tmp, file);
279 + } catch {}
280 + // Opportunistic GC (write-path only, so throttled to active turns): cancelled
281 + // renders leave `.cc-*.tmp` atomic-write orphans; ended sessions leave
282 + // `.cc-turn-*` markers. Sweep our own debris older than a day.
283 + try {
284 + const stale = now - 864e5;
285 + for (const f of fs.readdirSync(claudeDir)) {
286 + if (!((f.startsWith(".cc-") && f.endsWith(".tmp")) || f.startsWith(".cc-turn-"))) continue;
287 + const fp = path.join(claudeDir, f);
288 + try {
289 + if (fs.statSync(fp).mtimeMs < stale) fs.unlinkSync(fp);
290 + } catch {}
292 + } catch {}
264 295 return { turn, month: L.monthTotal || 0, burnRate };
357 388 if (branch === "(detached)") branch = "detached";
358 389 const col = dirty > 0 ? c.yellow : c.green;
359 - let s = col(`⎇${branch}`);
390 + let s = col(` ${branch}`); // U+E0A0 powerline branch glyph (Nerd Font)
360 391 if (dirty > 0) s += c.yellow(`●${dirty}`);
361 392 if (ahead) s += c.cyan(`↑${ahead}`);
362 393 if (behind) s += c.cyan(`↓${behind}`);
395 426 "commit", "review", "compress",
397 428 if (!valid.has(mode) || mode === "off") return "";
398 - let out = c.orange(mode || "full");
429 + let out = c.dim("caveman:") + c.orange(mode || "full"); // muted label, bright value
399 430 if (process.env.CAVEMAN_STATUSLINE_SAVINGS !== "0") {
401 432 const sf = path.join(claudeDir, ".caveman-statusline-suffix");

codex/config.toml

Modified
1 +approval_policy = "never"
2 +sandbox_mode = "danger-full-access"
3 +permission_profile = "disabled"
4 +approvals_reviewer = "user"
5 +service_tier = "fast"
1 6 project_doc_fallback_filenames = ["CLAUDE.md"]
8 +[windows]
9 +sandbox = "elevated"
11 +[notice]
12 +hide_full_access_warning = true
14 +[tui]
15 +theme = "inspired-github"
16 +status_line = ["model-with-reasoning", "current-dir", "project-name", "git-branch", "pull-request-number", "branch-changes", "context-used", "five-hour-limit", "weekly-limit", "context-window-size", "fast-mode", "thread-title", "task-progress"]
17 +status_line_use_colors = true
18 +session_picker_view = "comfortable"
19 +pet = "disabled"
21 +[tui.model_availability_nux]
22 +"gpt-5.5" = 4
3 24 [projects."/home/okr"]
4 25 trust_level = "trusted"
27 +[projects.'c:\users\okr']
28 +trust_level = "trusted"
30 +[projects.'c:\users\okr\.codex']
31 +trust_level = "trusted"
33 +[projects.'c:\users\okr\workspace']
34 +trust_level = "trusted"
36 +[projects.'c:\users\okr\workspace\dotfiles']
37 +trust_level = "trusted"
39 +[projects.'c:\users\okr\workspace\isp-insoft-cloud']
40 +trust_level = "trusted"
42 +[projects.'c:\users\okr\workspace\kkg']
43 +trust_level = "trusted"
45 +[projects.'c:\users\okr\workspace\kkg-cloud']
46 +trust_level = "trusted"
48 +[projects.'c:\users\okr\workspace\kkg5']
49 +trust_level = "trusted"
51 +[projects.'c:\users\okr\workspace\dotfiles\notes\isp-insoft\kultur\ki_roadmap']
52 +trust_level = "trusted"
6 54 [plugins."atlassian-rovo@openai-curated"]
7 55 enabled = true
12 60 [plugins."build-web-data-visualization@openai-curated"]
13 61 enabled = true
63 +[plugins."claude-skills@personal"]
64 +enabled = true
15 66 [plugins."codex-security@openai-curated"]
16 67 enabled = true

wezterm/bugabinga/options.lua

Modified
17 17 target = 'CursorColor',
19 19 cfg.unzoom_on_switch_pane = true
20 - cfg.scrollback_lines = 100000
21 + cfg.front_end = "WebGpu"
22 23 -- Prefer native Wayland only when launched from a Linux Wayland session.
23 24 -- Leaves X11, macOS, and Windows alone.

wezterm/bugabinga/status.lua

Modified
98 98 local host_domain = function ()
99 99 local triple = wez.target_triple or ''
100 - if triple:find( 'windows', 1, true ) then return 'WIN', wez.nerdfonts.dev_windows or '□', palette.warning end
101 - if triple:find( 'darwin', 1, true ) then return 'MAC', wez.nerdfonts.dev_apple or '□', palette.ui.important_local end
102 - if triple:find( 'linux', 1, true ) then return 'LIN', wez.nerdfonts.dev_linux or '□', palette.ui.important_local end
103 - if triple:find( 'bsd', 1, true ) then return 'BSD', wez.nerdfonts.dev_freebsd or '□', palette.ui.important_local end
104 - return 'LOC', wez.nerdfonts.cod_terminal or '□', palette.ui.important_local
100 + if triple:find( 'windows', 1, true ) then return 'WIN', wez.nerdfonts.dev_windows or ' ', palette.warning end
101 + if triple:find( 'darwin', 1, true ) then return 'MAC', wez.nerdfonts.dev_apple or ' ', palette.ui.important_local end
102 + if triple:find( 'linux', 1, true ) then return 'LIN', wez.nerdfonts.dev_linux or ' ', palette.ui.important_local end
103 + if triple:find( 'bsd', 1, true ) then return 'BSD', wez.nerdfonts.dev_freebsd or '󰣠 ', palette.ui.important_local end
104 + return 'LOC', wez.nerdfonts.cod_terminal or ' ', palette.ui.important_local
107 107 local domain_label = function ( domain )
108 - if domain == 'unix' then return 'MUX', wez.nerdfonts.cod_server or wez.nerdfonts.cod_terminal or '□', palette.info end
108 + if domain == 'unix' then return 'MUX', wez.nerdfonts.cod_server or wez.nerdfonts.cod_terminal or ' ', palette.info end
109 109 if not domain or domain == 'local' or domain == 'Local' then return host_domain() end
110 - if domain:find( '^WSL:', 1, false ) then return 'WSL', wez.nerdfonts.dev_linux or '□', palette.ui.important_local end
111 - if domain:find( '^scope:', 1, false ) then return 'EXE', wez.nerdfonts.cod_gear or '□', palette.warning end
112 - return ( domain:upper():gsub( '[^%w]', '' ):sub( 1, 3 ) .. 'LOC' ):sub( 1, 3 ), wez.nerdfonts.cod_terminal or '□', palette.ui.important_local
110 + if domain:find( '^WSL:', 1, false ) then return 'WSL', wez.nerdfonts.dev_linux or ' ', palette.ui.important_local end
111 + if domain:find( '^scope:', 1, false ) then return 'EXE', wez.nerdfonts.cod_gear or ' ', palette.warning end
112 + return ( domain:upper():gsub( '[^%w]', '' ):sub( 1, 3 ) .. 'LOC' ):sub( 1, 3 ), wez.nerdfonts.cod_terminal or ' ', palette.ui.important_local
115 115 wez.on( 'format-tab-title', function ( tab, tabs, panes, config, hover, max_width )
202 202 cfg.enable_tab_bar = true
203 203 cfg.hide_tab_bar_if_only_one_tab = false
204 204 cfg.use_fancy_tab_bar = false
205 - cfg.tab_max_width = 64
205 + cfg.tab_max_width = 128
206 206 cfg.show_tabs_in_tab_bar = true
207 207 cfg.show_new_tab_button_in_tab_bar = false
208 208 cfg.tab_bar_at_bottom = true
209 - cfg.status_update_interval = 1000

wezterm/bugabinga/window.lua

Modified
1 1 local wez = require 'wezterm'
3 3 return function ( cfg )
4 - cfg.window_background_opacity = 1.0
5 - cfg.window_decorations = 'RESIZE|NONE'
5 + cfg.window_decorations = wez.target_triple:find( 'windows', 1, true ) and 'RESIZE' or 'RESIZE|NONE'
6 6 cfg.use_resize_increments = true
7 7 cfg.adjust_window_size_when_changing_font_size = false

wezterm/bugabinga/workspace_switcher.lua

Modified
54 54 return choice_table
57 +local function is_dir( path )
58 + -- wezterm.read_dir returns children only if path itself is a directory.
59 + local ok, result = pcall( wezterm.read_dir, path )
60 + return ok and result ~= nil
61 +end
57 63 local function get_workspace_dir_elements( choice_table, workspace_ids )
58 64 local workspace_dir = wezterm.home_dir .. '/Workspace'
59 - local stdout = run_child_process { 'find', workspace_dir, '-mindepth', '1', '-maxdepth', '1', '-type', 'd' }
60 - local paths = wezterm.split_by_newlines( stdout )
65 + local ok, entries = pcall( wezterm.read_dir, workspace_dir )
66 + if not ok or not entries then return choice_table end
68 + local paths = {}
69 + for _, entry in ipairs( entries ) do
70 + if is_dir( entry ) then
71 + table.insert( paths, entry )
72 + end
73 + end
61 74 table.sort( paths )
62 75 for _, path in ipairs( paths ) do
63 76 add_path_element( choice_table, workspace_ids, path )