Files
dais/tools/README.md
T
Tommi Kyntola 944a09a7e9 Target release: free a slot digit for reuse
Durable persistence means a picked target stays picked even after its pane
dies — which is right, since dais-driven panes come and go. Release is the
missing complement: how you say you are done with one and hand the digit
back to the picker.

state/daemon:
- state/release-slot: refuses an unknown slot and the LAST remaining slot,
  and moves :active-slot to the next survivor when the active one goes.
  load-targets only honors the durable overlay while (get targets
  active-slot) resolves, so a dangling active slot would silently discard
  every persisted target on the next daemon start.
- target action "release"; persists through transition!'s existing :targets
  watch, so a release sticks across restarts exactly like a pick does.

dais-ctl: target release <slot>, plus slot completion in _dais-ctl.

dais-top: x then 1-5, sticky footer prompt, ? entry. It takes a digit rather
than acting on the picker's highlighted row because the usual reason to
release a slot is that its pane is GONE — and a gone pane has no row in the
picker, which only lists live tmux panes.

Also fixes the startup banner: it printed (:targets cfg) — config, not the
durable overlay the daemon actually runs with — so it misreported every
picked or released slot on every restart. Now reads the state atom, sorted,
with * marking the active slot.

config: drop the retired system:claude.0 slot.

ai/gotchas.md records two things this turned up: the
:active-slot-must-resolve invariant, and tmux pane_index being positional —
closing a pane renumbers those after it, so a stored "s:w.2" silently
retargets while still reading alive and green.
2026-08-17 12:23:40 +03:00

12 KiB
Raw Permalink Blame History

dais tools

Thin clients for the daemon's control socket ($XDG_RUNTIME_DIR/dais/control.sock, override with $DAIS_SOCKET).

The daemon runs as a systemd --user unit (tools/dais.service, symlinked into ~/.config/systemd/user/ and enabled): systemctl --user start dais, logs via journalctl --user -u dais. Running clojure -M:daemon directly is the foreground/dev path (add --dry-run to plan without executing, --no-ear to skip the audio worker) — stop the unit first so they don't share a socket.

Tool Purpose
dais-ctl Full verb set (node). Status, inject, targets, events, replay.
dais-top Live TUI cockpit: mode, mic level meter, heard-list, counters, targets.
dais-vad Toggle the VAD session. Bind to F9.
dais-rec Toggle the manual record latch. Bind to F10.
dais-esc Send Escape to the active target immediately. Bind to F11.

The three dais-* toggles are plain sh + socat with no PATH/zsh assumptions, so they work as KDE global shortcuts as-is. State lives in the daemon — the scripts are stateless one-liners.

Examples

Pipeline smoke test without a microphone (inject feeds a fake transcript into the router; with --dry-run nothing reaches tmux/ydotool):

tools/dais-ctl status
tools/dais-ctl inject press enter            # whole-utterance command
tools/dais-ctl inject choose option two      # grammar: fillers + ordinals
tools/dais-ctl inject please review PR 123   # dictation -> type-text, no submit
tools/dais-ctl inject voice off              # voice control of the daemon itself

Brief a fresh agent session about voice input (delivers a pointer to BRIEF.md into the target — the agent reads the file itself; --full pastes the whole text for targets without file access). Then say "press enter":

tools/dais-ctl brief

Real dictation via the latch (speak between the two rec calls):

tools/dais-ctl rec      # or press F10
# ... speak ...
tools/dais-ctl rec      # stop -> transcribe -> route -> deliver
tools/dais-ctl events 3 # see what happened

Targets (slot 1/2/... are defined in config/dais.edn and adjustable live):

tools/dais-ctl target list
tools/dais-ctl target set 2 app:claude.0 # a tmux pane (window NAMES work too)
tools/dais-ctl target set 1 focus        # the focused app (ydotool)
tools/dais-ctl target set 3 current      # grab the active tmux pane
tools/dais-ctl target use 2              # switch; or say "target two"
tools/dais-ctl target release 3          # forget slot 3, freeing the digit
tools/dais-ctl target next               # cycle to the next slot (= "next target")
tools/dais-ctl target prev               # cycle to the previous slot
tools/dais-ctl target next-live          # next deliverable slot (skips dead targets)
tools/dais-ctl target panes              # all panes, agents ★, slots annotated
tools/dais-ctl target pick [slot]        # fzf-pick a pane (default: active slot)

In dais-top, t opens the same picker as an overlay (↑/↓, Enter, then the slot digit). Picked targets are durable: the daemon persists them to ~/.local/state/dais/targets.edn and they override the config/dais.edn defaults on restart — delete that file to return to config defaults.

release is the complement: persistence means a slot you picked stays picked even after its pane dies (which is what you want — dais-driven panes come and go), so release is how you say you are done with one and hand the digit back to the picker. In dais-top press x, then the slot digit. It takes a digit rather than acting on the picker's highlighted row because the usual reason to release a slot is that its pane is gone — and a gone pane has no row in the picker. Releasing the active slot moves the active pointer to the next surviving slot; releasing the last remaining slot is refused (there would be nothing to deliver to).

Debugging a miss:

tools/dais-ctl events 20                 # recent events across the log
tools/dais-ctl replay <trace_id>         # full chain for one utterance
jq . "$XDG_RUNTIME_DIR/dais/state.json"  # mode/target/last utterance

One-shot command arming (the next utterance must be a command; a miss does nothing instead of being typed):

tools/dais-ctl arm
tools/dais-ctl off                       # force voice off
tools/dais-ctl shutdown                  # stop the daemon (cleans up socket/markers)

dais-top

tools/dais-top

Full-screen status cockpit: mode badge (pulsing while recording), a live mirrored waveform of the mic (green where the VAD heard speech, cyan ambient, flat gray baseline when quiet) with a Silero speech-probability meter (VAD mode only — the latch records to a file, so it shows a pulse animation instead), target slots with the active one highlighted, the last utterances with their outcome — dictation quoted (“…” → typed), interpreted commands marked » … → Enter in yellow, drops ✗ dropped: … — and today's counters (listened time, utterances, words, drops, mean ASR latency) seeded from the event log. A confidence-gated refusal (see :confidence-min-logprob in config/dais.edn) flashes uncertain — say again? with the heard text in the footer — repeating is cheaper than undoing garbage.

Control keys: v VAD toggle · r record latch · Esc send Escape · 1–5 switch target · Tab next live target (skips dead ones) · t target picker (tmux panes plus a ⌖ focus row, so a slot can always be pointed back at the focused app) · x release a slot, then 1–5 (frees the digit; any other key cancels) · a arm · m mute (warm pause) · d dry-run toggle · e cycle enter-mode · s cycle router strategy · w toggle airc, the Tesla terminal viewer (~/airc; an AIRC badge shows while broadcasting — it is a public tunnel; DAIS_AIRC overrides the tool path, absent tool hides it all) · ? help · q quit. The footer lists only the frequent keys; press ? for the full key + voice-command reference — it also lists the unobtrusive cycle keys (> next / < prev target) and your config commands, pulled live from the daemon so the list never drifts from config/dais.edn. The e/s toggles (also dais-ctl set enter-mode|strategy|language ...) are session-only — a daemon restart returns to the config defaults; calibration knobs (VAD tuning, idle timeout, confidence floor) stay config-file only on purpose. Language switching has no dais-top key on purpose: it only makes sense after swapping config to a multilingual model, so it stays a deliberate dais-ctl set language act.

Entirely optional: when no dais-top is connected the daemon broadcasts nothing and the ear skips level computation entirely (the daemon toggles the meter via set_levels on subscriber transitions) — zero overhead.

Voice commands

Daemon controls — {:control kw} commands, recognized in every router strategy (unprefixed/unarmed escape hatches). These are built-in default commands; bind your own phrases to the same actions in config (see Configuring commands):

Say Effect
"voice off" / "dais off" stop listening (in-flight latch recording is discarded)
"mute" / "unmute" warm pause: mic stays on but every utterance is dropped until "unmute"
"toggle dry run" flip dry-run: utterances still route and show in dais-top, but nothing reaches the target
"next target" cycle target slot
"target two" (one–five, ordinals, digits) switch slot

Built-in whole-utterance commands:

Say Effect
"scratch that" C-u — clear the input line
"cancel" / "stop" Escape
"yes" / "no" type yes/no + Enter

Key presses: trigger verb (press/hit/push/choose/select/pick/answer) + keys; fillers (the/a/and/then/option/number/key/button) ignored; max 5 keys. Keys: enter, return, escape, esc, up, down, left, right, tab, backspace, one–nine / first–ninth / digits, control|ctrl + a c d k u w.

"press enter"                      -> Enter
"choose option two"                -> 2
"select the third option"          -> 3
"press down and enter"             -> Down Enter
"press control a then control k"   -> C-a C-k (clear the line)

Every non-filler word must map to a key, or the utterance is dictation — "select the right abstraction for this" types as text. Everything that isn't a command is dictation: typed as one line, never submitted (:no-enter; with :enter-auto a trailing spoken "enter" submits).

Configuring commands

Add your own under config/dais.edn :router :commands — a phrase maps to:

:commands
{"clear"        {:keys ["C-u"]}                      ; press a key / chord
 "say hi"       {:text "hello" :submit true}         ; type text, then Enter
 "new terminal" {:keys ["C-M-t"]                     ; ctrl-alt-t (focus target)
                 :description "open a terminal"}      ; shown in dais-top ?
 "shush"        {:control :mute}}                     ; a daemon control (alias)

A {:control kw} entry runs a daemon control instead of delivering to the target — :voice-off, :next-target, :mute, :unmute, :toggle-dry-run. The built-in phrases above are just default :control commands, so this is how you add your own aliases (e.g. "shush" → mute). Control commands are escape hatches: they work in every strategy, unprefixed and unarmed.

Keypress chords are tmux-style: modifier prefixes C- ctrl, M- alt, S- shift, s- super, then a base key — letters, digits, Enter Escape Tab Space BSpace, arrows, Home End PgUp PgDn, F1–F12. The same chord renders to a tmux send-keys token and to ydotool keycodes, so a command works on either target (super and WM globals like C-M-t only do anything on a :focus target). Config commands are trusted, so they may use the full chord vocabulary; the narrow voice keypress grammar above is unchanged — speech can never synthesize a M-/C-M- chord.

:description is a one-liner listed under configured in the dais-top ? help overlay (without it, the overlay shows the synthesized effect).

A :macro runs an ordered list of steps against the active target — each step is {:text … :submit …}, {:keys […]}, or {:delay ms} (a pause). Top-level :delay paces between steps; a {:delay ms} step is an explicit wait. Steps run synchronously and stop at the first failure.

"setup leanheat"
{:description "cd into leanheat-app, new window, launch claude"
 :macro [{:text "cd ~/code/lh/leanheat-app" :submit true}
         {:text "tn app" :submit true}
         {:text "aclaude" :submit true}]
 :delay 120}                       ; ms between steps

"new terminal"
{:description "open a terminal, then maximize (focus target)"
 :macro [{:keys ["C-M-t"]}
         {:delay 400}              ; wait for the window
         {:keys ["C-M-Right"]}]}

A macro fires like any command — say its phrase, or dais-ctl inject "<phrase>". It runs entirely against whichever target is active, so point the right slot first (tmux pane for typing, focus for window-manager chords).

Statusline integration

$XDG_RUNTIME_DIR/dais/ holds state.json plus marker files meant for [ -f ... ] checks in a tmux powerline / Claude statusline segment:

[ -f "$XDG_RUNTIME_DIR/dais/mic-recording" ] && echo "🎤"
[ -f "$XDG_RUNTIME_DIR/dais/speech-detected" ] && echo "🗣"
[ -f "$XDG_RUNTIME_DIR/dais/muted" ]          && echo "🔇"
[ -f "$XDG_RUNTIME_DIR/dais/dry-run" ]         && echo "DRY"

zsh completion

tools/_dais-ctl completes every verb, the target/set sub-actions, and the enter-mode/strategy/language value sets. Slots (target use|set|pick), tmux panes (target set), and replay trace ids are read live — slots from the durable overlay ($DAIS_STATE_DIR, default ~/.local/state/dais/targets.edn) falling back to config/dais.edn, traces from the event log. Symlink it onto your $fpath and restart zsh:

ln -s "$PWD/tools/_dais-ctl" ~/.zsh/completion/_dais-ctl   # a dir on your $fpath

Keep it in sync with buildRequest() in dais-ctl when verbs change.