Files
brov-macbook/CLAUDE.md
T
maksarsanjeev 101a3860a9 Net core: re-create WireGuard tunnels after a network change (rebind)
mihomo's WireGuard outbounds keep their UDP socket bound to the address they started on:
after moving from Planet9 to Saga the Amnezia sockets were still sending from
192.168.68.x, so every Amnezia (and client) tunnel looked dead while the AmneziaVPN app,
connecting afresh, worked. Client tunnels now live in a file provider (keys/clients.yaml,
groups select them by filter) like the Amnezia keys; netctl rebind touches both files and
reloads the providers, which re-creates the tunnels on the current address without
touching other connections. BroV calls it on every network change before re-testing.
Tested on a scratch core: groups, selection across a rebind, health check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 15:54:16 +03:00

4.3 KiB

BroV — guide for AI coding agents

BroV is a personal, never-published fork of Coucou (github.com/Louis-CFM/coucou, MIT, imported at 83708fe). Native macOS app in NotchBuddy/: an animated character in the MacBook notch that shows Claude Code sessions, lets the user approve/answer from the notch, and chats — with the user's own claude CLI as its brain (no API key).

Where things are

  • NotchBuddy/Sources/App/ — Mac app code. NotchBuddy/Sources/CoucouKit/ — shared models, the character engine (BotEngine.swift), pills (PillCatalog.swift).
  • NotchBuddy/Sources/App/ClaudeCodeCLI.swift — runs claude -p … --output-format stream-json --resume <id> for the chat.
  • NotchBuddy/Resources/sounds/ — WAV sounds.
  • NotchBuddy/project.yml — XcodeGen project (never edit the .xcodeproj by hand; it is git-ignored and regenerated).

Build

bash scripts/build.sh   # xcodegen + xcodebuild, installs ~/Applications/BroV.app, relaunches
bash scripts/render-brov.sh   # character in every state → /tmp/brov-states.png

DerivedData must stay outside ~/Documents (iCloud adds Finder attributes and codesign fails).

Rules

  • Personal use only: never publish to GitHub or any public place. The original Coucou name, Mochi character and icon are not used in BroV.
  • Swift 6, SwiftUI + AppKit. One dependency: SwiftTerm (term.macOS tabs). The character is 11 Memoji images (Resources/memoji) moved by BotEngine at 30 fps.
  • Secrets live in the Keychain or the root-only network core folder, never in git.
  • Never block Claude Code: if the app doesn't answer, the hook exits immediately.
  • Never overwrite ~/.claude/settings.json: dated backup, merge, write only after the user confirms.
  • Never approve a Claude Code permission without an explicit click.
  • When spawning claude, strip CLAUDECODE from the environment and close stdin.
  • Pill IDs are stable contract values: never rename an existing pill ID.

Network core (globe 🌐 in the header)

  • mihomo runs as root: LaunchDaemon local.maksar.brov.netd, binary + config + keys + API secret in /Library/Application Support/BroV/ (root, 0700). Nothing user-writable is read by root.
  • BroV never sees the config or the API secret: it talks to the narrow root helper scripts/netcore/netctl.py (LaunchDaemon local.maksar.brov.netctl, socket /var/run/brov-netctl.sock, only the installing user) — commands: state, select, delay, tun (on = clean core restart, refused while the AmneziaVPN app is open; also points the Mac DNS into the core), add_key, hide, unhide, refresh, rebind (after a network change: re-creates the WireGuard tunnels, which otherwise stay bound to the old address).
  • scripts/netcore/gen.py builds the config (Amnezia keys → provider keys/amnezia.yaml, single vless:// links added in BroV → provider vless-keys from keys/vless.txt, WireGuard clients, VLESS subscription). Install/update: sudo sh scripts/netcore/install.sh (verifies the mihomo SHA256, migrates keys). Never commit keys, configs or the guide (~/.brov-secrets).
  • Reloading the whole core config drops every connection (including this chat); group switches and provider reloads don't.

BroV Ops (homelab manager, ops/)

  • Separate service on the homelab Ubuntu VM (Hyper-V): tasks with subtasks + timer, subscriptions + payments, routines. Python, SQLite, systemd (brov-ops), user brovops. Tests: python3 -m unittest discover -s ops/tests.
  • Free text → claude -p (Haiku, the user's subscription, logged in on the VM) → JSON actions; only the whitelist in brain.ALLOWED is applied, nothing is deleted. Voice from Telegram → faster-whisper on the VM first (Claude doesn't take audio).
  • Telegram and Claude are blocked from Russia: the service goes through its own proxy-only mihomo (brov-ops-proxy, 127.0.0.1:7890, VLESS subscription in /etc/brov-ops/proxy/vless.sub). No system-wide VPN on the VM.
  • Secrets (bot token, API token, subscription) only in /etc/brov-ops on the VM; BroV keeps the API token in the Keychain (brov-ops-token), URL in UserDefaults opsURL.
  • BroV side: Ops.swift — click on the Memoji opens the menu (Дела, timer, пипетка, переводчик, кофе); settings in Settings → Чат → «Дела (хоумлаб)». The ops service is independent of BroV and of the VPN core: restarting either doesn't touch the others.